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

后端 未结 9 843
栀梦
栀梦 2020-12-02 14:58

In particular, the display of initialization lists is really bad:

vector v({1,2,3});

will highlight the curly braces in red (den

相关标签:
9条回答
  • 2020-12-02 15:37

    As far as I know, there is a work in progress for that, see here at the vim_dev mail list.

    0 讨论(0)
  • 2020-12-02 15:38

    You can also configure this in a local syntastic config file.

    Drop a .syntastic_cpp_config file in your project root and give it the compiler arguments one per line (I also have include paths for the Loki library as an example):

    -std=c++11
    -Ilib/loki/include
    -Ilib/loki_book/include
    
    0 讨论(0)
  • 2020-12-02 15:47

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

    0 讨论(0)
  • 2020-12-02 15:49

    As an alternative, you can use

    let c_no_curly_error=1
    

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

    0 讨论(0)
  • 2020-12-02 15:58

    If you use 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 multiple languages. Each language has a "checker" which is a wrapper to execute an external program. The external program for the c++ checker is g++. The c++ checker can pass compiler options to g++ and can be configured.

    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++'
    
    0 讨论(0)
  • 2020-12-02 15:58

    I have searched the other proposals about C++11 syntax file of VIM and they are old and not maintained. Anyway, recent distributions of Vim have good syntax files already. Sometimes they are updated though and official source of syntax files is here: https://github.com/vim-jp/vim-cpp

    0 讨论(0)
提交回复
热议问题