当前位置: 动力学知识库 > 问答 > 编程问答 >

Indent brackets .5 shift width and block another .5 shift width using Allman style indentation in Vim

问题描述:

I'm aware of the Vim cinoptions variable to setup indentation, but I can't find if there's a way to align a scoped case block with the case keyword rather than the brace when using Allman style indentation. My current cinoptions are: cino=N-s,:0.5s,=0.5s,l1 (numbers behind the statement in the case block are to highlight spacing).

For example, using K&R or 1TBS style:

switch (switch_variable)

{

case 1: {

1234foo();

}

default:

}

works fine, whereas Allman:

switch (switch_variable)

{

case 1:

{

123456foo();

}

default:

}

has the block indented by a full-shiftwidth from the braces when what I want is:

switch (switch_variable)

{

case 1:

{

1234foo();

}

default:

}

Where the statements in the case block are a half-shiftwidth from the braces or a full-shiftwidth from the case statement. Is there way to align the code block with the case word so it's 1 shiftwidth from the case keyword?

This is not the same question as vim: C indent braces at the same level as case because I want the brackets indented by half a shift-width and the block indented half a shift-width relative to the brackets or a full shift-width relative to the case statement: not the brackets inline with the case statement and the block indented a full-shift width relative to the case statement.

分享给朋友:
您可能感兴趣的文章:
随机阅读: