Java 的 Vim 全方位补全
我读过很多关于 Vim 据称伟大的全能补全功能的博客,但无论我做什么,我都无法让它令人满意地工作。我花了很长时间才发现我的系统上预装的 ctags 版本是 emacs 版本,并且没有 --recurse 选项,但现在我已经在我的 OpenJDK 副本上运行了 ctags-exuberant尝试使用 [Cn] 或 [Cp] 调用它时,Vim 就会挂起。
我真正想要的只是像 Eclipse 中的代码完成一样工作;我喜欢 Vim 作为编辑器,但 Eclipse 只是具有那些 Vim 似乎无法提供的开箱即用的额外功能。带有 vi 模式插件的 Eclipse 对我来说并不是特别有用,而且它对内存和 CPU 的消耗太大,没有任何用处; eclim 也不怎么喜欢我。
谁能建议一种更简单的方法来在 Vim 中实现某种实际有效的代码完成功能?
I've read heaps of blogs on Vim's supposedly great omnicompletion, and yet no matter what I do I can't get it to work satisfactorily. It took me ages to figure discover that the version of ctags that is preinstalled on my system was the emacs one, and didn't have the --recurse option, but now that I've run ctags-exuberant on my copy of the OpenJDK sources to attempt to get some kind of code completion going, Vim hangs whenever I try to invoke it with [C-n] or [C-p].
All I really want is something that works like the code completion in Eclipse; I like Vim as an editor, but Eclipse just has those extra features out-of-the-box which Vim seems to fail with. Eclipse with a vi-mode plugin wasn't particularly useful to me, and it is too much of a memory and CPU hog to be of any use; eclim doesn't quite like me either.
Can anyone suggest a simpler way to get some kind of code completion working in Vim that actually works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是 vim 的“JDE”功能: http://www.vim.org/scripts/script.php?script_id=1213 一列出的功能之一是“代码完成(适用于 java 和 jsp、taglib、html、xml、xsl、xsd)(需要 VIM 7.0)”
,这是一个 Java 自动完成脚本: sourceforge.net/scripts/script.php?script_id=1785" rel="noreferrer">http://vim.sourceforge.net/scripts/script.php?script_id=1785
这不是 Java,但我发现它非常清晰易懂;也许它值得一读。这是为 Drupal 设置自动完成的秘诀。自定义 AWK 脚本为 vim 构建自动完成字典。 http://www.thingy-ma-jig.co。 uk/blog/18-08-2009/drupal-autocomplete-vim
祝你好运。
Here is a "JDE" feature for vim: http://www.vim.org/scripts/script.php?script_id=1213 One of the listed features is "Code completion ( working for java and jsp,taglib,html,xml,xsl,xsd) (VIM 7.0 required) "
And here is a Java autocompletion script: http://vim.sourceforge.net/scripts/script.php?script_id=1785
This one isn't Java, but I found it to be quite clear and understandable; perhaps it might be worth reading. Here is a recipe on setting up autocompletion for Drupal. A custom AWK script builds an autocompletion dictionary for vim. http://www.thingy-ma-jig.co.uk/blog/18-08-2009/drupal-autocomplete-vim
Good luck.
我尝试过 eclim:
http://eclim.sourceforge.net/
不久前,它基本上运行eclipse 在后台运行,然后提供一个 vim 插件,可以让你在 vim 中获得 eclipse 的所有功能。所以你可以进行重构、完成等。如果你不介意在系统后台运行一个巨大的 eclipse 进程,它似乎工作得很好。
我在 C++ 中完成得很好(无论如何都比 Vis Stud 更好),但在 java 中却没有太多运气。这些天我大部分时间都倾向于使用 eclipse,但我在 eclipse 中将 gvim --remote 设置为外部命令,这样我就可以随时将当前缓冲区擦除到 vim 中。
I had a go with eclim:
http://eclim.sourceforge.net/
A while ago, it basically runs eclipse in the background and then provides a vim plugin which lets you get at all the functionality of eclipse inside vim. So you can do refactoring, completion etc. It seems to work quite well if you don't mind running a huge eclipse process in the background on your system.
I've got completion working quite well in C++ (Better than Vis stud anyway) but never had much luck with java. These days I tend to use eclipse most of the time but I have gvim --remote set up as an external command in eclipse so that I can just wip the current buffer into vim anytime I want.
有同样的愿望,通过使用 eclim 实现了它。效果真的非常好。
Had the same desire, got it fulfilled by using eclim. Works really really well.
我已经寻找过这个,并且正在考虑从 eclipse 迁移到 vim。到目前为止,我找到的最好的解决方案是使用 vrapper( http://vrapper.sourceforge.net/ )。它将 vim 的许多功能带到 eclipse 编辑器中,并且您仍然可以使用自动完成功能和 Eclipse 的所有其他功能。
我仍然对完全迁移感兴趣,但对于 java 开发环境来说,似乎很难击败 eclipse。 (只是讨厌日食的开销!)
I have looked for this as well as I am considering moving from eclipse to vim. The best solution I have found so far is to bring vim to eclipse with the vrapper( http://vrapper.sourceforge.net/ ). It brings a lot of the features of vim to the eclipse editor and you can still use autocompletion and all the other features of Eclipse.
I am still interested in moving completely, but it seems difficult to beat eclipse for a java development environment. (just hate the overhead for eclipse!)