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.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
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