Avoiding label indenting in C++

2019-02-12 00:46发布

问题:

I guess this was asked before, but I could not find any similar question.

When writing part of the scope operator in C++, Vim guesses that it's going to be a label (on the first :) and then indents it automatically, which is pretty annoying. Example:

#1 - initial typing

{
    std

#2 - added :

{
std:

#3 - added :

{
    std::

Of course, it's correct at the end, but is there any way to disable the automatic indent for labels? I rarely use them, and it wouldn't be a great deal to indent manually in those cases.

回答1:

Just tell vim not to de-indent labels with:

:set cinoptions+=L0

For reference, if by "visibility" modifiers you mean access specifiers, these can be set to not indent with:

:set cinoptions+=g0