当前位置:  开发笔记 > 开发工具 > 正文

用vim排列函数参数列表

如何解决《用vim排列函数参数列表》经验,为你挑选了2个好方法。

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

def myfunction(arg1, arg2, arg, ...
               argsN-1, argN)

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

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



1> rampion..:

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

:set cino=(0

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


在我意识到不应该输出之前,缩进根本不起作用!变量的值只是:**(0**

2> solinent..:

我相信你必须发出命令:

:set cino=(0

这当使用cindent时.

编辑:我错过了"设置"

推荐阅读
殉情放开那只小兔子
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有