How to avoid namespace content indentation in vim?

前端 未结 5 694
慢半拍i
慢半拍i 2020-12-24 11:57

How to set vim to not indent namespace content in C++?

namespace < identifier >
{
    < statement_list > // Unwanted indentation
}
5条回答
  •  渐次进展
    2020-12-24 12:44

    As many have mentioned Google C++ style is quite good. I 'd recommend to install clang-format which I find it better than the recommended plugins, and then install a vim plugin on top.

    Install clang-format

    Ubuntu:

    sudo apt-get install clang-format
    // or for older versions:
    sudo apt-get install clang-format-3.6
    

    Mac:

    brew install clang-format
    

    Vim plugin:

    rhysd/vim-clang-format

    Install using your favorite plugin manager. Checkout the plugin's link for more options. The default style is google, but there is also llvm and others.

    One option you might need if you are using a custom version of the command is for

    example:

    let g:clang_format#command ="clang-format-3.6"
    

提交回复
热议问题