Easily reformatting function arguments onto multiple lines in Vim
arguments, formatting, vim
Solution
You can use splitjoin.
SomeObject doSomething(firstType argumentOne, secondType argumentTwo, thirdType argumentThree);
Inside or on brackets, type `gS` to split. You get:
SomeObject doSomething(firstType argumentOne,
secondType argumentTwo,
thirdType argumentThree);
You can also use vim-argwrap
Problem
Particularly when editing legacy C++ code, I often find myself manually reformatting something like this: ``` SomeObject doSomething(firstType argumentOne, secondType argumentTwo, thirdType argumentThree); ``` to something like this: ``` SomeObject doSomething(firstType argumentOne, secondType argumentTwo, thirdType argumentThree); ``` Is there a builtin command to do this? If not, can someone suggest a plugin or provide some VimScript code for it? (`J` or `gq` can reverse the process very easily, so it need not go both ways.)