Coder Social home page Coder Social logo

vim-cpp-modern's Introduction

vim-cpp-modern: Enhanced C and C++ syntax highlighting

Keyword and regex-based syntax highlighting for C and C++11/14/17/20/23 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

out 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 virtual, override, final, inline, explicit and export are standard C++ statements and not types and are therefore highlighted using the highlight group Statement.
  • 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.

Optional features

" 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:

  • C: static, register, auto, volatile, extern, const, inline, __attribute__, restrict, alignas, alignof, static_assert, noreturn, thread_local, struct, union, enum, case, default
  • C++: class, typename, template, namespace, concept, mutable, constexpr decltype, consteval, constinit

Installation

$ 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 :help packages.

License

Distributed under the same terms as Vim itself. See :help license.

vim-cpp-modern's People

Contributors

bfrg avatar garzet avatar shauncox avatar toruniina avatar ytian81 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.