简体   繁体   English

VIM中的自动代码完成?

[英]Auto code completion in VIM?

Can VIM do auto code completion like what Eclipse does? VIM可以像Eclipse那样自动执行代码完成吗? Usually I connect to my Linux developing server through Putty from my Windows laptop. 通常我从Windows笔记本电脑通过Putty连接到我的Linux开发服务器。 So, I hope I can find a plugin for VIM which can do drop-down menu like auto completion when I can type variable names in Putty, is this possible? 所以,我希望我能找到一个VIM的插件,当我可以在Putty中键入变量名时,可以执行自动完成等下拉菜单,这可能吗?

Thanks! 谢谢!

Yes, in a sense - Vim has Completion commands that can help you automatically find the completion text for partial variable names. 是的,从某种意义上说 - Vim有完成命令可以帮助您自动查找部分变量名称的完成文本。

In a nutshell, type a partial variable name and then press Ctrl P to search for a matching name. 简而言之,键入部分变量名称,然后按Ctrl P搜索匹配的名称。

Yes, it's possible. 是的,这是可能的。 Vim already features that general style of code completion built-in, under the name of Omni completion. Vim已经具有内置的一般代码完成风格,名称为Omni完成。

The default installation doesn't allow for auto-invocation, but if you install this script , that allows it to happen. 默认安装不允许自动调用,但如果安装此脚本 ,则允许它发生。

Note that, depending on the language you'll be working with, you may need additional scripts to handle auto-completion for that language, and may even need to change the auto-invoke script to recognize when to invoke the completion. 请注意,根据您将使用的语言,您可能需要其他脚本来处理该语言的自动完成,甚至可能需要更改自动调用脚本以识别何时调用完成。 Since you haven't said what programming language you'll want to work with, it's a bit hard to say if you need more than this, but I recommend checking the help file. 既然你还没有说过你想要使用的编程语言,那么如果你需要更多的编程语言就有点难了,但我建议你查看帮助文件。

Try to use http://eclim.org/ - using eclipse core with VIM via plugins. 尝试使用http://eclim.org/ - 通过插件使用带有VIM的eclipse核心。

To not start the complete ecplise core but have a C/C++ member completion, try http://www.vim.org/scripts/script.php?script_id=1520 要不启动完整的ecplise核心但已完成C / C ++成员,请尝试http://www.vim.org/scripts/script.php?script_id=1520

-   Complete namespaces, classes, structs and union members. 
-   Complete inherited members for classes and structs
(single and multiple inheritance). 
-   Complete attribute members eg: myObject->_child->_child etc...

Currently vim has no of plugins for the auto code completion feature, I am using youcompleteme plugin, combined with vim-snippets , ultisnips and supertab plugins. 目前vim没有自动代码完成功能的插件 ,我使用youcompleteme插件,结合vim-snippetsultisnipssupertab插件。 You can tab complete the code using snippets (a small text which can be expanded for full code), and a large number of languages are supported. 您可以使用片段(可以扩展为完整代码的小文本)选项卡来完成代码,并支持大量语言。

For simple text files also a drop down menu comes for the words you have typed earlier. 对于简单的文本文件,还会为您之前键入的单词提供下拉菜单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM