Is there a way to remove blank lines from a region of code I select?
I am asking because I copy/pasted code and it seems to have several blank lines I want to get rid off.
C-x hto select the whole buffer.
M-x flush-lines RETfollowed by
^[[:space:]]*$ contain the meta-characters:
^for beginning of string,
$for end of string,
[[:space:]]*zero or more spaces.
Ergo, if the first two meta-characters are next to each other or if there is one or more spaces between them, it must be a blank line. Source
You may eventually be interested by shrink-whitespace