Reputation: 52840
The tip. The errors are "E349: No identifier unders cursor", "E433: No tags file" and "E426: tag not found: public". I feel them unrelated or I cannot understand their message. I have the code in "~/.vimrc" and pressed "F1", "F9" and "ESC". A related tip but more advanced. so how can I add Java import statements automatically in Vim?
[Added] I use Eclipse on the side but when it is down-or-slow-or-compiling-or-doning-something-stupid I use Vim. So stop here. What are the errs for?
Upvotes: 6
Views: 8237
Reputation: 2720
Cursor needs to be over an identifier
It seems like the tip requires you to position the cursor over a class name for which it will then insert the import statement. "No identifier under cursor"-error shows up when the mapping tries to use the <C-W>} command when there is no word under the cursor.
ctags
The other errors show up because it also uses the command <C-W>} which requires you to have a ctags file containing the tags for the project. That can be generated with a ctags utility. Exuberant ctags is quite nice for that purpose:
Here is some information about using ctags for java (although on my system I don't have a command exuberant-ctags, it's just ctags):
http://blog.vinceliu.com/2007/08/vim-tips-for-java-2-using-exuberant.html
Tip quality
It looks like the mapping in that tip clobbers the default register, search register and changes the last change command, the jump stack, the tag stack and moves the cursor. So it's a quick'n dirty tip, not very elegant.
Upvotes: 3
Reputation: 41775
You might want to give Eclim a try, which provides a very nice integration of Eclipse features into Vim. In their own words:
"[Eclim] provides an Eclipse plug-in that exposes Eclipse features through a server interface, and a set of Vim plug-ins that communicate with Eclipse over that interface."
Upvotes: 5
Reputation: 40769
I am a dyed in the wool VI programmer, but I know to use the right tools for the right job. If you want automatic inclusion of import statements while you're coding, just use an IDE already. Eclipse is great; you can even shell out to VIM sometimes if you need to.
Upvotes: 1