How can I format string concatenations ("abc" + "def") as paragraph formatting in Vim?
Suppose I have this piece of code
var t = "abc abc abc abc abc abc abc abc abc abc " +
"abc abc abc abc abc abc abc abc abc";
I am editing the first row but it is over 80 columns in my editor
var t = "abc abc abc abc abc abc abc abc abc ABC ABC ABC abc" +
"abc abc abc abc abc abc abc abc abc";
I don't like to have this in my code, so I need to format all lines
var t = "abc abc abc abc abc abc abc abc abc " +
"ABC ABC ABC abc abc abc abc abc abc " +
"abc abc abc abc";
Is it possible to solve this using something like gq}
or do you know a plugin that could help me?
source to share
Until you find the plugin, you can record a macro qq
, jump right 80 times 80l
, jump to the end of a word before ge
, add a
" + <ENTER> "<Esc>
, save a macro q
.
Then you will attach the following lines with J
and remove unnecessary templates " + "
.
You can play the macro again with @q
.
source to share