用vim排列函数参数列表

ind*_*ion 13 vim whitespace editor

当定义或调用具有足够参数的函数来跨越多行时,我希望vim将它们排成一行.例如,

def myfunction(arg1, arg2, arg, ...
               argsN-1, argN)
Run Code Online (Sandbox Code Playgroud)

这个想法是让argsN-1的'a'与args1对齐.

有没有人有办法在vim中自动发生这种情况?我已经看到对齐插件用于衬里等号(在赋值语句中)等等,但我不确定是否可以解决这个问题?

ram*_*ion 11

之前的海报有它,但忘记了 set

:set cino=(0<Enter>
Run Code Online (Sandbox Code Playgroud)

:help cinoptions-values

The 'cinoptions' option sets how Vim performs indentation.  In the list below,
"N" represents a number of your choice (the number can be negative).  When
there is an 's' after the number, Vim multiplies the number by 'shiftwidth':
"1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc.  You can use a
decimal point, too: "-0.5s" is minus half a 'shiftwidth'.  The examples below
assume a 'shiftwidth' of 4.

...

    (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))
                 {                         {
Run Code Online (Sandbox Code Playgroud)

  • 在我意识到<Enter>不应该输出之前,缩进根本不起作用!变量的值只是:**(0** (3认同)

sol*_*ent 7

我相信你必须发出命令:

:set cino=(0
Run Code Online (Sandbox Code Playgroud)

这当使用cindent时.

编辑:我错过了"设置"