简而言之,我正在为Vim编辑器寻找一个工作的自动完成功能。我以前说过,Vim完全取代了Linux下的IDE,虽然这是真的,但它缺少一个重要的特性:自动补全。

我知道Ctrl+N, Exuberant Ctags集成,Taglist, cppcomplete和OmniCppComplete。唉,这些都不符合我对“工作自动完成”的描述:

Ctrl+N works nicely (only) if you've forgotton how to spell class, or while. Oh well. Ctags gives you the rudiments but has a lot of drawbacks. Taglist is just a Ctags wrapper and as such, inherits most of its drawbacks (although it works well for listing declarations). cppcomplete simply doesn't work as promised, and I can't figure out what I did wrong, or if it's “working” correctly and the limitations are by design. OmniCppComplete seems to have the same problems as cppcomplete, i.e. auto-completion doesn't work properly. Additionally, the tags file once again needs to be updated manually.

我知道,即使是现代的、成熟的ide也没有提供好的c++代码补全功能。这就是为什么直到现在我都接受了Vim在这方面的不足。但是我认为基本级别的代码完成要求并不过分,实际上是高效使用所必需的。所以我在寻找至少可以完成以下事情的东西。

Syntax awareness. cppcomplete promises (but doesn't deliver for me), correct, scope-aware auto-completion of the following: variableName.abc variableName->abc typeName::abc And really, anything else is completely useless. Configurability. I need to specify (easily) where the source files are, and hence where the script gets its auto-completion information from. In fact, I've got a Makefile in my directory which specifies the required include paths. Eclipse can interpret the information found therein, why not a Vim script as well? Up-to-dateness. As soon as I change something in my file, I want the auto-completion to reflect this. I do not want to manually trigger ctags (or something comparable). Also, changes should be incremental, i.e. when I've changed just one file it's completely unacceptable for ctags to re-parse the whole directory tree (which may be huge).

我忘记什么了吗?请随时更新。

我对相当多的配置和/或修补工作都很熟悉,但我不想从头开始编写解决方案,而且我不擅长调试Vim脚本。

最后提醒一下,我真的希望Java和c#也能有类似的东西,但我想这太不可能了:ctags只解析代码文件,而且Java和c#都有巨大的预编译框架,需要建立索引。不幸的是,在没有IDE的情况下开发。net比c++更像一个PITA。


当前回答

我来的有点晚了,但是autocomplpop可能会有帮助。

其他回答

我来的有点晚了,但是autocomplpop可能会有帮助。

有人提到code_complete吗?

http://www.vim.org/scripts/script.php?script_id=1764

但你不喜欢标签,所以这可能不是你要找的…

你想要的是智能感知之类的东西吗?

Insevim似乎解决了这个问题。

这里有截图链接

YouCompleteMe试试。它通过libclang接口使用Clang,提供语义C/ c++ /Objective-C补全。它很像clang_complete,但是速度更快,并且带有模糊匹配。

除此之外,YCM还为c#、Python、Go、TypeScript等提供语义补全。它还为没有语义支持的语言提供了非语义的、基于标识符的补全。

我刚刚在另一个问题中找到了Eclim项目。这看起来很有前途,至少对于Java集成来说是这样。