'make'
for C, but is customised specifically for Java. While the support for make
works with vim by default, certain changes have to be made for vim in order to make it work properly for Java.Add the following lines in your .vimrc:
autocmd BufRead *.java set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
autocmd BufRead set makeprg=ant\ -find\ build.xml
As long the
build.xml
file is in the parent directory of where the Java files you are working on is located, vim will be able to locate it, compile the changed files and inform you of where the compilation errors are.All that's remaining is just to type
:make
, and you now have automatic compilation from within Vim!If you like reading this, you may also enjoy:
- Vim Tips for Java #2: Using exuberant-ctags
- Vim Tips for Java #3: Use Omni-Completion (or Intellisense) for Automatic Syntax Completion
- Vim Tips for Java #4: Using 'tab' for Syntax Completion
- Vim Tips for Java #5: Folding Code Blocks to Prevent Visual Blindness
- Vim Tips for Java #6: Auto-Bracketing Within Vim
4 comments:
have you tried ant_menu?
http://www.vim.org/scripts/script.php?script_id=155
Hi Pipping,
No I haven't. Thanks for that, I'll give it a try.
Cheers!
Thanks for that, I'll give it a try.
I have a question:
My log is like this
MainActivity.java|25| not a statement
MainActivity.java|25| ';' expected
And can't find a suitable errorformat expression to match this. Vim always can't find the file because the file path has not matched. So can i make ant to print full path or configure vim to match the file?
Post a Comment