c++ - 我如何使用 vim cindent 实现这一点?

标签 c++ vim indentation

如果我此刻在vim中写出如下代码

const SomeType & some_function (<ENTER>

然后 vim 将在两个制表符的缩进处继续下一行。我希望它仅用一个制表符缩进下一行。

我知道cindent存在,但我不知道是什么 syntax将使这一切发生。

最佳答案

: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))
             {                         {

关于c++ - 我如何使用 vim cindent 实现这一点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7808939/

相关文章:

c++ - 带协商的 Telnet 客户端服务器 session

Vim - 复制每行的第 N 个字,从第 10-100 行到行尾

c# - 如何缩进 XML 文本并保留 C# 中的换行符?

c++ - unordered_set<Foo> 作为 Foo 的数据成员?

c++ - 如何从 ifstream 获取格式化输入

vim - 为什么我的 'jk' zsh vi-cmd-mode 绑定(bind)不起作用

vim - (g)Vim 中的 "un-tab"序列是什么?

java - 让 Java 使用制表符而不是空格来缩进

c++ - 获取错误 C2440 : char[]* to char* (pointers)

session - 如何在 Vim 中保存和恢复多个不同的 session ?