Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete empty lines in a file using Emacs?

In Emacs, how to remove all empty lines (including tabs and spaces) in file?

Can M-x replace-regexp do the trick?

I can find the empty lines with regexp: ^[st]*$, but don't know how to replace it by deleting.

like image 290
herbertD Avatar asked Oct 21 '14 03:10

herbertD


1 Answers

M-x flush-lines RET ^[[:space:]]*$ RET is probably the canonical way to do that.

like image 153
Stefan Avatar answered Nov 15 '22 05:11

Stefan