Search code examples
c++vimindentationauto-indent

How to avoid namespace content indentation in vim?


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

namespace < identifier >
{
    < statement_list > // Unwanted indentation
}

Surprisingly, 'cinoptions' doesn't provide a way to edit namespace content indentation.


Solution

  • Not sure when it was introduced but my installed version of vim, v7.3.353 has a cino option that handles cpp namespace explicitly. I am currently using the example value:

    cino=N-s

    and as per :help cinoptions-values

    NN    Indent inside C++ namespace N characters extra compared to a
      normal block.  (default 0).
    
    cino=                      cino=N-s 
      namespace {                namespace {
          void function();       void function();
      }                          }
    
      namespace my               namespace my
      {                          {
          void function();       void function();
      }                          }
    

    The link the OP posted is for v7.3.162