Monday, December 16, 2019

Replacing Single Line Spacing with Double Line Spacing in VIM

Thanks to this post, I learned on how to replace blank lines in my text document into 2 blank lines, to make it neat and clear.

The original document, with single line spacing


My objective is to replace all single blank lines representing new lines, into 2 new lines instead. To do that in vim, I just need to press "escape" to enter command mode and type the command below, which is ":%s/^$/\r/g", where
%s is to replace all occurrence of the selection in a line
^$ for single blank lines
\r carriage return, which will print double blank lines



The result should be like below 


Save and quit as usual, and you get yourself a neater document with double line spacing. Enjoy :)