How to avoid namespace content indentation in vim?

freitass picture freitass · Mar 30, 2010 · Viewed 7.1k times · Source

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.

Answer

mmlb picture mmlb · Nov 14, 2011

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