为C ++配置Vim

问题描述 投票:102回答:3

我想让vim成为我的C ++编辑器。我使用它的经验很少,需要帮助配置vim才能使用C ++。我需要这样的功能

  • 代码完成(对于stl和我的类)
  • 在.cc和.h文件之间切换
  • 你可能会有更多技巧,C ++和vim大师。

也许你可以提供一些配置(有解释),或链接到教程,我可以使用的插件?

c++ vim configuration
3个回答
129
投票

编辑:自2013年7月更新


8
投票

我使用vim作为我的C ++编辑器,但是我没有使用很多“异国情调”的东西。

  • 关于完成,我使用非上下文^P^N
  • 我有一堆用户定义的缩写用于我的C ++使用,例如: abbreviate bptr boost::shared_ptr abbreviate cstr const std::string &
  • 我有几个函数用于“代码片段”之类的东西,例如: function! IncludeGuard() let basename = expand("%:t:r") let includeGuard = '__' . basename . '_h__' call append(0, "#ifndef " . includeGuard) call append(1, "#define " . includeGuard) call append(line("$"), "#endif /* !" . includeGuard . " */") endfunction
  • 我真的不能没有的唯一插件是Command-T(需要红宝石支持)
  • 为了方便.cc.h切换,你可以尝试this plugin

2
投票

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

丰富的ctags(vim本身已经支持热键)http://ctags.sourceforge.net/

taglist:http://vim-taglist.sourceforge.net/

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

我不做omnicompletion只是通常^ n ^ p的东西,但谷歌有足够的资源。

© www.soinside.com 2019 - 2024. All rights reserved.