Tip #830: Using netbeans 4 and vim for java
tip karma |
Rating 5/4, Viewed by 2007
|
created: |
|
December 7, 2004 2:02 |
|
complexity: |
|
basic |
author: |
|
Ivan F. Villanueva B. |
|
as of Vim: |
|
6.0 |
This tip explains how to configure Vim to build Java sources and to execute classes without having to start Netbeans, but everything done in the same way Netbeans would do it. Netbeans can then be started any time to do things that Vim cannot, like debugging in a GUI or refactoring.
This has been tested in Linux.
It is assumed that your Java source code is in the directory "~/data/java/src" and that your classes are in different packages below this directory. For example the package com.your_domain.util is in the directory "~/data/java/src/com/your_domain/util"
Step 1: Install Ant
Step 2: Install Netbeans and create a new project with existing sources. At this point you can choose within Netbeans where all project files will be saved. Let say "~/data/java/netbeans" and the project name is "my_domain". The source code directory should be the top directory, here: "~/data/java/src". Netbeans will add packages in the project for all subdirectories, which allows to move classes between packages with the mouse, and Netbeans will refactor your whole source files for you.
Step 3: Compile your project with Netbeans. After that you can close Netbeans.
Step 4: Add the following two lines in .vimrc or in ~/.vim/ftplugin/java_netbeans.vim or ...
nmap <F6> :! ant -buildfile ~/data/java/netbeans/my_domain/build.xml compile<CR>
nmap <F7> :cd ~/data/java/src<CR>:! ant -buildfile ~/data/java/netbeans/my_domain/build.xml -Drun.class=%:.:r -Djavac.includes=~/data/java/netbeans/my_domain/build/classes/ run-single<CR>:cd %:p:h<CR>
That's it ! Now you can compile changed files pressing <F6> or execute the class you are editing with <F7> in Vim. And you can start anytime Netbeans for debugging, refactoring, etc.
<<copy & paste between vim session |
regexp to strip redundant zeroes in decimal fractions >>
Additional Notes
|