Is there a C ++ 11 syntax file for vim?

In particular, displaying initialization lists is really bad:

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

will highlight curly brackets in red (indicating an error).

+64
c ++ vim c ++ 11
Jun 04 '10 at 19:29
source share
9 answers

Now there is a C ++ 11 script from http://www.vim.org/scripts/script.php?script_id=3797 that no longer marks the brackets inside the brackets as an error.

+32
Dec 16 2018-11-12T00:
source share

Alternatively you can use

 let c_no_curly_error=1 

in your .vimrc file so that vim doesn't mark {} as an error in () .

+34
Jan 26 2018-11-11T00:
source share

If you are using Syntastic , add this to your .vimrc (or .vimrc.local).

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

Syntastic shows errors for code written in several languages. Each language has a "checker", which is a shell for executing an external program. An external program for checking C ++ is g ++. The C ++ controller can pass compiler parameters to g ++ and can be customized.

https://github.com/scrooloose/syntastic/wiki/C--:---gcc

If you want to use clang ++, you can use these options

 let g:syntastic_cpp_compiler = 'clang++' let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++' 
+24
Nov 19 '12 at 22:31
source share

use standard initialization instead of the old () constructor

vector v {1,2,3};

+9
May 01 '11 at 19:33
source share

As far as I know, there is work for this, see here in the list of letters vim_dev.

+6
Jun 08 '10 at 19:15
source share

An improved patch for C ++ 11 support was sent to the mailing list: https://groups.google.com/forum/?fromgroups#!topic/vim_dev/ug_wmWQqyGU

+4
Jun 09 2018-12-12T00:
source share

You can also configure this in a local configuration syntax file.

Drop the .syntastic_cpp_config file into the project root directory and give it compiler arguments one per line (as an example, I also included the paths for the Loki library):

 -std=c++11 -Ilib/loki/include -Ilib/loki_book/include 
+1
May 7 '14 at 16:07
source share

If you use YouCompleteMe, you can change the ".ycm_extra_conf.py" as follows: (file path ~ / .vim / bundle / YouCompleteMe / third_party / ycmd / cpp / ycm / .ycm_extra_conf.py);

change flags

 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/', 

]

+1
Aug 09 '16 at 15:30
source share

I was looking for other suggestions about the C ++ 11 VIM syntax file, and they are old and not supported. In any case, the latest Vim distributions already have good syntax files. Sometimes they are updated, and the official source of the syntax files is here: https://github.com/vim-jp/vim-cpp

0
Nov 03 '15 at 12:19
source share



All Articles