How to remove all the empty new lines in a document with one command?
vim
Solution
Try `:g/^$/d`, which will remove all blank lines. The `g` indicates `global`, the `^$` is a regular expression that basically means 'match lines that start and end with nothing in between', and the `d` means `delete`. You can mix and match as much as you need :)
Another space-related command that may come in handy if you have random whitespace is `:%s/\s\+$//`, which trims any trailing whitespace (as @Bernhard points out, the `$` operator means that you have a max of one occurrence per line, so the `g` is unnecessary).
Per the update, possible that the lines already contain whitespace, in which case `:g/^\s*$/d` should work.
Problem
My document looks something like this: ``` Line number one Line number two Line number three ``` I want the whole document to look like this: ``` Line number one Line number two Line number three ``` In other words, to remove all the empty lines. How to accomplish this?