Ⅰ. 插件描述
Extended Vim syntax highlighting for C and C++ (C++11/14/17/20)Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'bfrg/vim-cpp-modern'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'bfrg/vim-cpp-modern'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'bfrg/vim-cpp-modern'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/bfrg/vim-cpp-modern
Ⅳ. 文档说明
# vim-cpp-modern: Enhanced C and C++ syntax highlighting
Keyword and regex-based syntax highlighting for C and C++11/14/17/20 in Vim.
The syntax files provide highlighting of:
- Common ANSI C keywords
- C++ Standard Library namespaces, types, helper types, helper template
variables, constants - Latest C++20 language features like Coroutines or Concepts
- Function declarations/definitions and function calls (basically all words
followed by an opening parenthesis) - Optionally a simpler (less colorful) highlighting of standard C and C++
keywords
Difference to vim-cpp-enhanced-highlight
Both syntax files are based on vim-cpp-enhanced-highlight with a few
modifications:
- The C++ keywords
virtual,override,final,inline,explicitand
exportare standard C++ statements and not types and are therefore put
under the highlighting group Statement.
- Highlighting of library functions is purely regex-based.
- User-defined function templates or class members are not highlighted. Their
regex'es are too complicated and slow, and fail too often.
Optional features
" Disable function highlighting (affects both C and C++ files)
let g:cpp_no_function_highlight = 1
" Put all standard C and C++ keywords under Vim's highlight group 'Statement'
" (affects both C and C++ files)
let g:cpp_simple_highlight = 1
" Enable highlighting of named requirements (C++20 library concepts)
let g:cpp_named_requirements_highlight = 1The last option will highlight all C++ named requirements (concepts that
haven't made it into the C++ standard yet) as standard library types.
Installation
Copy both c.vim and cpp.vim into your ~/.vim/after/syntax directory, or
use your preferred plugin manager.
Issues
Vim tends to a have issues with flagging braces inside brackets as invalid
syntax such as in the following example:
std::map<std::pair<int, int>, int> m;
m[{1, 2}] = 3;As a workaround set
let c_no_curly_error = 1See also :help ft-c-syntax for further options.
License
Distributed under the same terms as Vim itself. See :help license.