特别是在编辑遗留 C++ 代码时,我经常发现自己手动重新格式化如下内容:
SomeObject doSomething(firstType argumentOne, secondType argumentTwo, thirdType argumentThree);
到这样的事情:
SomeObject doSomething(firstType argumentOne,
secondType argumentTwo,
thirdType argumentThree);
是否有内置命令来执行此操作?如果没有,有人可以建议一个插件或提供一些 VimScript 代码吗? (J
或 gq
可以很容易地反转这个过程,所以它不需要双向。)
最佳答案
您可以使用 splitjoin .
SomeObject doSomething(firstType argumentOne, secondType argumentTwo, thirdType argumentThree);
在括号内或括号上,键入 gS
进行拆分。你得到:
SomeObject doSomething(firstType argumentOne,
secondType argumentTwo,
thirdType argumentThree);
您也可以使用vim-argwrap
https://stackoverflow.com/questions/12733909/