Vim是否有C ++ 11语法文件?

特别是,初始化列表的显示非常糟糕:

vector<int> v({1,2,3}); 

将突出红色的花括号(表示错误)。

现在有一个来自http://www.vim.org/scripts/script.php?script_id=3797的C ++ 11脚本,它不再将括号内的括号标记为错误。

作为替代,你可以使用

 let c_no_curly_error=1 

在你的.vimrc文件中,这样vim不会在()标记为{}

如果您使用Syntastic ,请将其添加到.vimrc (或.vimrc.local)。

 let g:syntastic_cpp_compiler_options = ' -std=c++11' 

Syntastic显示用多种语言编写的代码的错误。 每种语言都有一个“检查器”,它是一个执行外部程序的包装器。 c ++检查器的外部程序是g ++。 c ++检查器可以将编译器选项传递给g ++,并且可以进行configuration。

https://github.com/scrooloose/syntastic/wiki/C–:—gcc

如果你想使用clang ++,你可以使用这些选项

 let g:syntastic_cpp_compiler = 'clang++' let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++' 

使用统一的初始化而不是旧的()构造函数

向量v {1,2,3};

据我所知,有一个正在进行的工作,在这里看到在vim_dev邮件列表。

C ++ 11支持的改进补丁已发送到邮件列表: https : //groups.google.com/forum/?fromgroups#!topic/ vim_dev/ ug_wmWQqyGU

你也可以在本地合成的configuration文件中configuration它。

.syntastic_cpp_config文件放到你的项目根目录下,每行给它一个编译器参数(我也有Loki库的includepath作为例子):

 -std=c++11 -Ilib/loki/include -Ilib/loki_book/include 

如果你使用YouCompleteMe,你可以改变'.ycm_extra_conf.py',就像这样:(file path〜/ .vim / bundle / YouCompleteMe / third_party / ycmd / cpp / ycm / .ycm_extra_conf.py);

只改变标志

 flags = [ '-std=c++11', '-O0', '-Werror', '-Weverything', '-Wno-documentation', '-Wno-deprecated-declarations', '-Wno-disabled-macro-expansion', '-Wno-float-equal', '-Wno-c++98-compat', '-Wno-c++98-compat-pedantic', '-Wno-global-constructors', '-Wno-exit-time-destructors', '-Wno-missing-prototypes', '-Wno-padded', '-Wno-old-style-cast', '-Wno-weak-vtables', '-x', 'c++', '-I', '.', '-isystem', '/usr/include/', 

]

我已经search了关于VIM的C ++ 11语法文件的其他build议,他们是旧的,而不是维护。 无论如何,Vim最近的发行版本已经有了很好的语法文件。 有时候他们会被更新,官方的语法文件来源在这里: https : //github.com/vim-jp/vim-cpp