Here's a quick sub to remove all the empty lines in a file. I use this to cleanup after macros that leave a bunch of blanks.
:%s/^\n//
Subscribe to:
Post Comments (Atom)
A blog dedicated to text editing and general exploration of computing knowledge
3 comments:
Hi !
Your blog is very cool, it made me use H J K and L keys rater than the arrow keys in vim ^^ !
To remove blank lines, you can also do
:%g/^$/d
Since sometimes, \n does not work (I saw that once on AIX with vi)...
Wow, that's great! Glad you're enjoying the blog and thanks for the tip.
Really a nice blog, so much tips about vim, great, thanks.
Outside vim:
$ grep -v '^$' file
$ grep '.' file
$ sed '/^$/d' file
$ sed -n '/^$/!p' file
$ awk NF file
$ awk '/./' file
http://unstableme.blogspot.com
Post a Comment