How can I align my python arguments quickly in Vim. New to tabular plugin and cannot figure out command for aligning arguments properly:
Have this:
myfunc(arg1=value1,
arg2=value2,
arg3=value3,
arg4=value4,
arg5=value5,
arg6=value6,
arg7=value7)
Want this:
myfunc(arg1=value1,
arg2=value2,
arg3=value3,
arg4=value4,
arg5=value5,
arg6=value6,
arg7=value7)
You don't actually need Tabular.vim for this. Put your cursor at the top of myfunc
(or a bit higher) and press =}
(or =)
). This runs equalprg
across your function block to indent it appropriately.
From the help on '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.
BTW, if you do want to learn more about Tabular and its use cases, there’s a great video on vimcasts.