Vim 使用 Tabularize 对齐 Python 个参数

Vim Align Python Arguments with Tabularize

如何在 Vim 中快速调整我的 python 参数。表格插件的新手,无法找出正确对齐参数的命令:

有这个:

myfunc(arg1=value1,
       arg2=value2,
 arg3=value3,
       arg4=value4,
   arg5=value5,
   arg6=value6,
   arg7=value7)

想要这个:

myfunc(arg1=value1,
       arg2=value2,
       arg3=value3,
       arg4=value4,
       arg5=value5,
       arg6=value6,
       arg7=value7)

您实际上不需要 Tabular.vim。将光标放在 myfunc 的顶部(或更高一点),然后按 =}(或 =))。这会在您的功能块中运行 equalprg 以适当地缩进它。

来自 'equalprg' 上的帮助:

External program to use for "=" command. When this option is empty the internal formatting functions are used; either 'lisp', 'cindent' or 'indentexpr'. When Vim was compiled without internal formatting, the "indent" program is used. Environment variables are expanded |:set_env|. See |option-backslash| about including spaces and backslashes. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons.

顺便说一句,如果您想了解有关表格及其用例的更多信息,可以查看 great video on vimcasts.