tags:

views:

7645

answers:

5

I'm addicted to vim, it's now my de facto way of editing text files.

Being that it's mainly a text editor and not an IDE, has anyone got tricks for me to make it easier when developing java apps.

Some questions I have:

  • How do I invoke a maven task without leaving vi
  • Can I get code completion?
  • How's the syntax highlighting?

Anything else other than "Don't do it!!!" that I should know about?

Thank you.

+3  A: 

Use vim. ^-^ (gVim, to be precise)

You'll have it all (with some plugins).

Btw, snippetsEmu is a nice tool for coding with useful snippets (like in TextMate). You can use (or modify) a pre-made package or make your own.

Berzemus
+3  A: 

I see Java in the foreseeable future at work, and I plan to use vim.

Code completion is available through omni completion. There is also ^N and ^P in insert mode which work well.

I imagine the Java syntax highlighting is well-developed.

Greg Hewgill
+12  A: 

Some tips:

  • Make sure you use vim (vi improved). Linux and some versions of UNIX symlink vi to vim.
  • You can get code completion with eclim
  • Or you can get vi functionality within Eclipse with viPlugin
  • Syntax highlighting is great with vim
  • Vim has good support for writing little macros like running ant/maven builds

Have fun :-)

toolkit
command to get help on java syntax highlighting.:help java.vim
mike
+1  A: 
ngn
+2  A: 

I've been a vim user for years. I'm starting to find myself starting up eclipse occasionally (using the vi plugin which...I have to say, has a variety of issues). The main reason is that java builds take quite a while...and they are just getting slower and slower with the addition of highly componentized build-frameworks like maven. So validating your changes tends to take quite a while, which for me seems to often lead to stacking up a bunch of compile issues I have to resolve later, and filtering through the commit messages takes a while.

When I get too big of a queue of compile issues, I fire up eclipse. It lets me make cake-work of the changes. It's slow, brutal to use, and not nearly as nice of an editor as vim is (I've been using vim for nearly a decade, so it's second nature to me). I find for precision editing -- needing to fix a specific bug, needing to refactor some specific bit of logic, or something else...I simply can't be as efficient at editing in eclipse as I can in vim.

Also a tip: :set path=** :chdir your/project/root

This makes ^wf on a classname a very nice feature for navigating a large project.

So anyway, the skinny is, when I need to add a lot of new code, vim seems to slow me down simply due to the time spent chasing down compilation issues and similar stuff. When I need to find and edit specific sources, though, eclipse feels like a sledge hammer. I'm still waiting for the magical IDE for vim. There's been three major attempts I know of. There's a pure viml IDE-type plugin which adds a lot of features but seems impossible to use. There's eclim, which I've had a lot of trouble with. And there's a plugin for eclipse which actually embeds vim. The last one seems the most promising for real serious JEE work, but it doesn't seem to work very well or really integrate all of eclipse's features with the embedded vim.

Things like add a missing import with a keystroke, hilight code with typing issues, etc, seems to be invaluable from your IDE when working on a large java project.

Anyway, have fun.

I recently packaged up all the stuff I use for vim ­— it's available here:http://www.blisted.org/blog/mvn-0.0.1
Scott S. McCoy