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, and constants
- C++11 attributes
- Latest C++20 language features like coroutines and 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
Code snippet from cppreference (left: default syntax file, right: this plugin).
Difference to vim-cpp-enhanced-highlight
Both syntax files are based on vim-cpp-enhanced-highlight with the following modifications:
- The C++ keywords
exportare standard C++ statements and not types and are therefore highlighted using the highlight group
- Highlighting of library functions is purely regex-based.
- User-defined function templates, class names in declarations, and class scopes are not highlighted. Their regex'es are too complicated and slow, and fail too often.
" Disable function highlighting (affects both C and C++ files) let g:cpp_function_highlight = 0 " Enable highlighting of C++11 attributes let g:cpp_attributes_highlight = 1 " Highlight struct/class member variables (affects both C and C++ files) let g:cpp_member_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
The last option changes the highlighting of the following keywords:
$ cd ~/.vim/pack/git-plugins/start $ git clone --depth=1 https://github.com/bfrg/vim-cpp-modern
Note: The directory name
git-plugins is arbitrary, you can pick any other
name. For more details see
Distributed under the same terms as Vim itself. See