emacs strip blank lines

Spiral-Bound Pad

Spiral-Bound Pad (by incurable_hippie)

Here is a quick way to strip (remove) blank lines from a file with emacs.

  1. position on top of file: M-<
  2. Call a query-regex-replace: M-C-%
  3. input the regex ^ C-q C-j that stand for match all lines that consist in only a carriage return.
  4. RET-RET. The first one confirm the regex and the last one is for “replace with nothing”.
  5. When asked use ! to replace-all.

Summing all commands:

M-< C-M-% ^ C-q C-j RET RET !

here you are 🙂

Advertisements

One thought on “emacs strip blank lines

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s