27

I love vim, but not having things like IntelliSense/Code completion from Eclipse makes it pretty difficult. I know, I know, I should be able to look at method signatures and java docs for the API I am interested in using. I'd love to, but I'd like it to be accessible from my fingertips instead of having to browse the source tree manually or have a JDK reference handy.

What plugins would make this easier?

Nick Stinemates
  • 41,511
  • 21
  • 59
  • 60

8 Answers8

22

I tried eclim for a while. It was pretty good, basically it uses eclipse in the background as a kind of engine and provides a plugin to let you use all of eclipses goodness through vim.

http://eclim.org/

Chris Knadler
  • 2,819
  • 2
  • 26
  • 32
Benj
  • 31,668
  • 17
  • 78
  • 127
  • 1
    I think eclim even lets you have full blown eclipse running but with vim as a kind of child window inside it. Very impressive really. – Benj Oct 31 '09 at 23:19
  • 2
    Also check out vrapper. It's a lightweight version. It just enable vim key binding on Eclipse. – Yada Nov 24 '09 at 21:10
  • Could you explain the "for a while" part? I'm guessing you found some limitations of it compared to whatever you use now. – Sridhar Sarnobat Jul 31 '21 at 17:23
17

Don't write Java in Vim — put Vim inside a Java IDE:

I love Vim, but using an IDE for Java is the only way to stay sane. A decent Java IDE will:

  • Show invalid syntax or type errors
  • Show missing JavaDoc
  • Manage import statements for you
  • Highlight unused methods and variables
  • Safely perform powerful refactorings such as moving methods or renaming classes -- (no, search and replace doesn't cut it, I promise)
  • Reformat your code automatically or on-demand

Vim can't do the above, but you can use all the Vim keybindings in a program which does.

a paid nerd
  • 30,702
  • 30
  • 134
  • 179
  • 2
    I will vouch for jVi. The developer still works on it and is receptive to bug reports and feature requests. – gotgenes Nov 25 '09 at 14:54
  • 1
    I used IdeaVIM for a few years, too. Other than the undo history getting corrupted after having IntelliJ open for a week, it worked great. – a paid nerd Jan 19 '11 at 19:15
  • +1 for jVi - it is excellent. Plus, I filed a bug report and the developer gave me a good deal of time to help sort it. – Jon Cairns Mar 05 '12 at 09:08
  • I'll vouch personally for viPlugin (which I bought) and IdeaVIM. Both have their share of bugs but are overall wonderful improvements. – a paid nerd Mar 05 '12 at 19:00
  • 4
    Why is everybody in the Java world so against vim? – Craige Feb 21 '13 at 19:08
  • @Craige It's not hatred towards Vim, it's hatred towards trying to write Java without completion and refactoring tools. I wouldn't hire someone that called themselves a Java programmer and spent 5% of their time manually rearranging import statements. – a paid nerd Feb 22 '13 at 15:52
  • 2
    @apaidnerd - It seems like your qualm should be with the Java language, rather than the developer. In any case, tools exist to work with Java in vim just fine. Imports can be managed automagically by JavaImp.vim – Craige Mar 09 '13 at 19:12
  • 4
    Having developed extensively in vim, emacs, Eclipse (and variants like Aptana), Xcode, Visual Studio, IntelliJ for many languages from scripting languages to Java, {,Objective-}C{,++,#} I can say I've never been more productive than with vi or emacs (once you learn them with the right extensions). – Chuck Aug 14 '13 at 18:08
7

I use Eclipse + Vrapper. Enables the vi dual mode editing we all know and love. <ESC>

Completely free and lightweight. The goal is to have the comfort and ease which comes with the different modes, complex commands and count/operator/motion combinations which are the key features behind editing with Vim, while preserving the powerful features of the different Eclipse text editors, like code generation and refactoring.

While eclim is another alternative, I feel eclim takes over Eclipse and vrapper doesn't.

Yada
  • 30,349
  • 24
  • 103
  • 144
  • Viable is a new vim plugin for eclipse that IMO improves on vrapper http://viableplugin.com/ – Leopd Aug 16 '11 at 21:27
  • BEWARE: The Viable plugin hasn't been updated since 2011 and the viableplugin.com web site seems to be owned by link spammers. – Brent Matzelle Aug 01 '13 at 14:59
5

Check out the JDE plugin for Vim. It provides Java omni-completion and a documentation viewer (among other things).

Ayman Hourieh
  • 132,184
  • 23
  • 144
  • 116
  • 2
    Have you actually used the JDE plugin? When I tried it, it seemed a bit confused. It doesn't have a very good rating either considering the number of times it's been downloaded. – Benj Oct 31 '09 at 23:17
  • I tried it for a while but I don't use it on a day-to-day basis. It looked OK back then. – Ayman Hourieh Oct 31 '09 at 23:26
  • Used it a while ago, and it seemed pretty good. There were enough quirks with it that I disabled it and started mousing. – Sam Barnum Nov 05 '09 at 16:40
  • Are you saying it was good or it wasn't? You seem to be saying both :-) – Benj Nov 06 '09 at 10:44
5

I use the javacomplete.vim plugin for omni-completion for java. It's a very nice script: it also shows the method signatures on top of the omni-completion. The downside is that it is a bit slow, but it has worked fine for me otherwise. Eclim might be better ut I haven't tried it yet so I can't comment on it.

I've also used the jcommenter.vim plugin for generating javadoc comments. It can parse method signatures and automatically add the relevant @param foo fields and such.

For the API searching I would suggest on overriding the K key on normal mode. It searches man pages for the keyword under the cursor, but the behavior can be overriden by setting the keywordprg variable. See this thread for an example.

Other scripts which I've found very useful (not specific to Java development): NERDCommenter, AutoClose, snipMate, Align.

Community
  • 1
  • 1
sluukkonen
  • 2,566
  • 1
  • 19
  • 12
3

There's an IntelliJ VIM plugin as well. Plus, IntelliJ is released an open-source, free version.

Sam Barnum
  • 10,559
  • 3
  • 54
  • 60
  • Also IntelliJ is a much nicer editor with smarter completion, re-factoring and intentions support. I have been using the free version for a couple of weeks and its pretty good quality for a beta version. (Some of the previous betas were not so good) – Peter Lawrey Nov 01 '09 at 09:11
3

Vim is not an IDE replacement. But very specific additional tool. With Vim you should only do small-fast tweaks while the main development is going under Netbeans/Eclipse/IDEA.

One more time. It is a Bad Bad Bad idea to turn Vim into Full IDE. Why? It won't be so fast. And thus won't be so pretty.

Here is scenario. You have opened Eclipse or whatever to edit your current task. And in 10 minutes you have to switch to another Task which is kind of urgent. The task is to tweak a little a maven or an ant built script and/or some deployment perl/python/groovy scripts.

How much time will it take to reload Eclipse to work on a new 5 minutes task and switch back?
But if you are Vim guru you can handle this in seconds. You can change one file and run Ant/Mvn within Vim.

And this is the power of Vim. You can change and check one file in no time no matter which extension it has: java, groovy, c++, makefile, bash, c#, etc.

Mykola Golubyev
  • 57,943
  • 15
  • 89
  • 102
  • I agree and disagree so I don't know which way to vote your submission. I have been using NetBeans in conjunction with vim as you say, but only for debugging purposes. Debugging is the one true thing I will open the IDE for (and as such, have it always open..) because even if VI could do it well, I don't think it could do it as well as Eclipse/NetBeans. – Nick Stinemates Nov 02 '09 at 15:37
  • Netbeans Good at editing Maven pom files and Refactoring. All searches I do within vim. – Mykola Golubyev Nov 03 '09 at 12:16
0

This will be an uphill battle. There is so much knowledge about your program built into Eclipse, that I expect you will eventually have to reimplement it all to be happy.

Any particular reason you cannot just decide you like the built-in editor in Eclipse?

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • Because it's terrible and way too heavy for the Java hacking I do. I also like to develop remotely, and having to carry around the IDE on all of my machines really isn't practical. – Nick Stinemates Oct 31 '09 at 22:58
  • 1
    In my experience the conveniences in a modern Java IDE justifies its size and use of resources. Many people like JetBrains IntelliJ which has just come out in a Community Edition. It might even be runnable over a "ssh -Y..." connection. It appears that a good place to start would be the VIM JDE - http://www.vim.org/scripts/script.php?script_id=1213. – Thorbjørn Ravn Andersen Oct 31 '09 at 23:45
  • To contribute my experience: I'm sometimes forced to run Eclipse remotely on my job. With a good local connection it can be run with ssh -XY as Thorbjorn suggests, but from a little further away, i.e. an outside VPN, this feels like playing piano with boxing gloves. However, with TightVNC (or any of its sibling programs) it becomes nearly as zippy as local that I can forget I'm remoting. – Carl Smotricz Nov 24 '09 at 21:08