I would set the register to a predefined macro. After some tests, I got the following:
let @x="/\\w\\+ \\w\\+(\nf(_:s\\(\\w\\+\\)\\@<=,/,\\r /g\n"
Using this line in your vimrc, you can format the methods by executing the x: @x macro with the cursor over the line you want to format. It adds 12 spaces for indentation, specified as follows:
| SomeObject doSomething(firstType argumentOne, secondType argumentTwo, thirdType argumentThree);
After executing the macro: @x you get
SomeObject doSomething(firstType argumentOne, secondType argumentTwo, thirdType argumentThree);
If you are in the function definition line, you can simply do the replacement:
:s\(\w\+\)\@,<=,/,\r /g
This is easy to put in display:
nmap <F4> :s/\(\w\+\)\@<=,/,\r /g<CR>
rbernabe
source share