Reputation: 3196
First and foremost please don't scream "Use an IDE" at me. I have given eclipse a chance and it is... okay but I'm much faster in vim than eclipse.
Basically the one thing that I wish vim could do that eclipse does is syntax checking on the fly. In eclipse if you have a syntax error the line is given an error marker and the file-name at the top shows a little red thing to let you know there are errors. I have been trying to get this in vim. I've looked at syntastic (which doesn't have checkers for Java) but I can't seem to make it work. So the question remains...
Is there any way to check syntax every time I save a file with vim? Hopefully have it show up in the status line naming how many errors and what line the first error is on...
Upvotes: 10
Views: 6505
Reputation: 12583
I'm new to Java, and after trying a few IDE's I went back to vim. So far I have had good experience with these two plugins
A good autocompletion plugin should be installed installed also (I have javacomplete2 working nicely with YouCompleteMe)
For both of these to work, I have the following in my .vimrc:
augroup java
au!
autocmd FileType java setlocal omnifunc=javacomplete#Complete
autocmd BufReadPost,BufWritePost *.java :NeomakeFile
# ...
augroup end
Before using Neomake, I tried using Syntastic for linting. But that plugin has no async support, thus after writing a file, I have to wait a second or so for my vim to become responsive.
Upvotes: 0
Reputation: 3738
The new JavaComplete plugin can give you some support for Java, including for Java 8.
Upvotes: 2
Reputation: 300
I realise this already has an accepted solution but vim purists might prefer to use Syntastic
It comes pre-configured for many of the common languages like PHP, Java etc. Just thought I'd leave this here in case other people have the same question but don't want to run a headless eclipse server to achieve it.
Upvotes: 8
Reputation: 86974
I haven't tried it and it's probably and overkill, but FYI there's the Eclim project which attempts to bring Eclipse's functionality to vim. It claims to do Java Validation along with many more features including code completion and code correction.
Upvotes: 4