在 VIM 中开发 Java 有哪些好的插件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1655844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are some good plugins for developing Java in VIM?
提问by Nick Stinemates
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.
我喜欢 vim,但是没有像 Eclipse 中的 IntelliSense/Code 完成这样的东西使它变得非常困难。我知道,我知道,我应该能够查看我有兴趣使用的 API 的方法签名和 Java 文档。我很乐意,但我希望它可以从我的指尖访问,而不必手动浏览源代码树或手边有 JDK 参考。
What plugins would make this easier?
什么插件会让这更容易?
采纳答案by Benj
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.
我尝试了 eclim 一段时间。非常好,基本上它在后台使用eclipse作为一种引擎,并提供一个插件让您通过vim使用所有eclipse的优点。
回答by Thorbj?rn Ravn Andersen
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.
这将是一场艰苦的战斗。关于您的程序内置于 Eclipse 中的知识太多了,我希望您最终必须重新实现这一切才能快乐。
Any particular reason you cannot just decide you like the built-in editor in Eclipse?
您不能决定喜欢 Eclipse 中的内置编辑器的任何特殊原因?
回答by Ayman Hourieh
Check out the JDE plugin for Vim. It provides Java omni-completion and a documentation viewer (among other things).
回答by Sam Barnum
There's an IntelliJ VIM pluginas well. Plus, IntelliJ is released an open-source, free version.
还有一个IntelliJ VIM 插件。此外,IntelliJ 发布了一个开源免费版本。
回答by Mykola Golubyev
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.
Vim 不是 IDE 的替代品。但非常具体的附加工具。使用 Vim,当主要开发在 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.
再一次。把 Vim 变成完整的 IDE 是一个坏主意。为什么?不会那么快。因此不会那么漂亮。
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.
这是场景。您已打开 Eclipse 或任何编辑当前任务的工具。在 10 分钟内,您必须切换到另一个紧急任务。任务是稍微调整 maven 或 ant 构建的脚本和/或一些部署 perl/python/groovy 脚本。
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.
重新加载 Eclipse 以处理新的 5 分钟任务并切换回来需要多长时间?
但是如果你是 Vim 大师,你可以在几秒钟内处理这个。您可以更改一个文件并在 Vim 中运行 Ant/Mvn。
And this is the power of Vim. You can changeand checkone file in no time no matter which extension it has: java, groovy, c++, makefile, bash, c#, etc.
这就是 Vim 的力量。您可以随时更改和检查一个文件,无论它具有哪种扩展名:java、groovy、c++、makefile、bash、c# 等。
回答by sluukkonen
I use the javacomplete.vimplugin 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.
我使用javacomplete.vim插件来完成 java 的全方位完成。这是一个非常好的脚本:它还在 omni-completion 之上显示了方法签名。缺点是它有点慢,但在其他方面对我来说效果很好。Eclim 可能会更好,但我还没有尝试过,所以我无法对此发表评论。
I've also used the jcommenter.vimplugin for generating javadoc comments. It can parse method signatures and automatically add the relevant @param foo fields and such.
我还使用了jcommenter.vim插件来生成 javadoc 注释。它可以解析方法签名并自动添加相关的@param foo 字段等。
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 keywordprgvariable. See this threadfor an example.
对于 API 搜索,我建议在正常模式下覆盖 K 键。它在手册页中搜索光标下的关键字,但可以通过设置keywordprg变量来覆盖该行为。有关示例,请参阅此线程。
Other scripts which I've found very useful (not specific to Java development): NERDCommenter, AutoClose, snipMate, Align.
我发现非常有用的其他脚本(并非特定于 Java 开发):NERDCommenter、AutoClose、snipMate、Align。
回答by Yada
I use Eclipse + Vrapper. Enables the vi dual mode editing we all know and love. <ESC>
我使用 Eclipse + Vrapper。启用我们都知道和喜爱的 vi 双模式编辑。<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.
完全免费且轻量级。目标是拥有不同模式、复杂命令和计数/运算符/动作组合带来的舒适性和易用性,这些是使用 Vim 进行编辑的关键功能,同时保留不同 Eclipse 文本编辑器的强大功能,如代码生成和重构。
While eclim is another alternative, I feel eclim takes over Eclipse and vrapper doesn't.
虽然 eclim 是另一种选择,但我觉得 eclim 接管了 Eclipse 而 vrapper 没有。
回答by a paid nerd
Don't write Java in Vim — put Vim inside a Java IDE:
不要在 Vim 中编写 Java — 将 Vim 放在 Java IDE 中:
I love Vim, but using an IDE for Java is the only way to stay sane. A decent Java IDE will:
我喜欢 Vim,但使用 Java IDE 是保持理智的唯一方法。一个体面的 Java IDE 将:
- 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
- 显示无效的语法或类型错误
- 显示缺少的 JavaDoc
import
为您管理报表- 突出显示未使用的方法和变量
- 安全地执行强大的重构,例如移动方法或重命名类——(不,搜索和替换不会削减它,我保证)
- 自动或按需重新格式化您的代码
Vim can't do the above, but you can use all the Vim keybindings in a program which does.
Vim 不能执行上述操作,但您可以在执行此操作的程序中使用所有 Vim 键绑定。