How do I reduce a range of empty lines into one line only?
You can use the following command to reduce a range of empty lines into one line only:
The explanation for this command is below:
:v/./ Execute the following command for all lines not containing a character (empty lines). ., Use the current line as the start of the range of lines. /./ Use the line containing a character as the last line. -1 Adjust the range of lines to end with the line before the last line. j Join the lines in the range. Note that this will give an error message if the empty lines are at the end of the file. To correct this, you have to add a temporary line at the end of the file, execute the command and then remove the temporary line. For more information, read: :v :join cmdline-ranges collapse