While things like looking up an API call while you are in the thick of coding are irritating, the effects of such distractions are often much more profound. A recent article by the New York Times suggests that such interruptions do not just result in the reduction of your efficiency, but increase the chances of making mistakes as well.
In vim 7.0, there is a facility that allows you to have auto-suggestion capabilities, which comes bundled for a number of languages like Ruby, Python, etc, but however not for Java. If you have followed my tip in using exhuberant-ctags for Java, the modification will allow vim to have primitive syntax completion capabilities, by using
<CTRL-P>. In this case, it tries to match a word you've typed with all the keywords found in ctag's tag file.
The problem with this approach, is that it performs 'dumb' keyword completion of previous matching patterns, rather than the 'intelligent' contextual syntax completion. This can lead to mistakes in suggestions, which can be rather frustrating.
For true contextual syntax completion, there are a few plugins out there works for Java. By and large, they aren't as polished as Netbeans, but still, they are quite functional and and usable. I've used a number of them in the past before, and the one that I reccomend for you to install is vjde.
While the plugin is quite usable, the documentation can use some working on. The default instructions requires you to install it in the
/etc/vimglobal directory, something I'm not willing to do in fear of of messing up my default installation's configurations. Fortunately instructions for local installation is pretty straightforward:
1) Download the latest copy of vjde;
2) Uncompress the downloaded .tar archive;
3) Copy the
syntax/directories to your
In order to use the completion, use the
<CTRL-X><CTRL-U>keystroke, which will provide you with an Intellisense-like syntax completion capability. Have fun with your new syntax-completion capability, and keep on vimming!
If you like reading this, you may also enjoy:
- Vim Tips for Java #1: Build Java files with Ant Automatically
- Vim Tips for Java #2: Using exuberant-ctags
- 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