我如何用vim cindent实现这一目标?

时间:2011-10-18 14:30:43

标签: c++ vim indentation

如果我现在在vim中编写以下代码

const SomeType & some_function (<ENTER>

然后vim将在两个标签的缩进处继续下一行。我希望它只用一个标签缩进下一行。

我知道cindent存在,但我无法解决syntax会使这种情况发生的原因。

1 个答案:

答案 0 :(得分:2)

:help cinoptions-values

(N    When in unclosed parentheses, indent N characters from the line
      with the unclosed parentheses.  Add a 'shiftwidth' for every
      unclosed parentheses.  When N is 0 or the unclosed parentheses
      is the first non-white character in its line, line up with the
      next non-white character after the unclosed parentheses.
      (default 'shiftwidth' * 2).

        cino=                     cino=(0 >
          if (c1 && (c2 ||          if (c1 && (c2 ||
                      c3))                     c3))
              foo;                      foo;
          if (c1 &&                 if (c1 &&
                  (c2 || c3))           (c2 || c3))
             {                         {