Tuesday, October 4, 2011

Vim - Join Lines with a Comma (or any other character)

Step 1 : Put the desired character at the end of each line. I will use a "," as an example

:%s/$/,/g

Step 2 : Join the lines together

%j!

1 comment:

Anonymous said...

Great tips! Thanks. I think you can leave out the g here, though, since the EOL should only occur once per line:

:%s/$/,/g

to

:%s/$/,/

and %j! should be :%j!

thanks!