简而言之,我正在为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。


当前回答

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

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

其他回答

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

Insevim似乎解决了这个问题。

这里有截图链接

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

有人提到code_complete吗?

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

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

还有clang_complete,它使用clang编译器为c++项目提供代码补全功能。关于这个插件的故障排除提示还有另一个问题。

这个插件似乎在项目编译时工作得很好,但对于大型项目来说速度非常慢(因为它试图进行完整的编译来生成标签列表)。

根据要求,以下是我之前的评论:

来看看这个:

Vim集成到MonoDevelop 至少对于。net的东西。 OmniCompletion

如果你想在MacOSX上使用monodevelop,这个链接应该会对你有帮助

祝你好运,快乐编码。