Replace multiple empy lines with one using Vim

To replace multiple empty lines into one empty line using Vim

Steps:

:silent! argdo %s#\v^\_$\n\_^$##ge | update | %s#\($\n\s*\)\+\%$##ge | update | wq
vim `find .  -type -f -iname "*.txt"` -s command.vim

This will turn the content of the file like this

Some file


with some empty line


into something like

Some file

with some empty line

Happy Hacking!

comments powered by Disqus