:g/^$/dBreaking this down. The "g" will execute a command on lines that match a regular expression. The regular expression matches blank lines, and the command is "d" (delete).
Showing posts with label lines. Show all posts
Showing posts with label lines. Show all posts
Thursday, December 19, 2013
Removing Blank Lines
Here's a handy one-liner to remove blank lines from a file.
Thursday, May 8, 2008
Reverse Lines in a File
You can quickly reverse all lines in a file using the following ex command.
:g/^/m0
This is particularly useful for files that are in chronological order such as logs or email mbox files. Thanks to Skyler for submitting the tip.
:g/^/m0
This is particularly useful for files that are in chronological order such as logs or email mbox files. Thanks to Skyler for submitting the tip.
Friday, May 2, 2008
Remove Empty Lines
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//
:%s/^\n//
Subscribe to:
Posts (Atom)