lining up function parameter lists with vim

前端 未结 4 1625
迷失自我
迷失自我 2021-01-04 07:30

When defining or calling functions with enough arguments to span multiple lines, I want vim to line them up. For example,

def myfunction(arg1, arg2, arg, ...         


        
4条回答
  •  清酒与你
    2021-01-04 08:06

    you might get some good mileage out of using a language-specific external tool as a Vim filter. for example, if you can write a Perltidy config file to generate the formatting you want (it looks like you would want the -lp -vtc=2 flags), you can then pipe your existing Vim buffer through it with

    :!/path/to/tidy -config /path/to/configfile
    

    if you're going to be running this sort of command frequently, you can define an command by putting something like the following in your .vimrc:

    command -range=% Tidy ,!/path/to/tidy -config /path/to/configfile
    

提交回复
热议问题