Absolutely. And it is extremely useful to do that. M-x flush-lines
and M-x keep-lines
are your friends, as well as just C-k
etc.
(The first thing you need to do is of course C-x C-q
, to make the buffer writable.)
If you use library Grep+ (grep+.el
) then you have these commands, which remove comment lines and toggle such removal:
grepp-remove-comments
, grepp-toggle-comments
, which are bound in grep buffers to ;
and M-;
, respectively.
(Grep+ also gives you commands that make it easy to have multiple grep buffers: +
(grepp-new-buffer
), b
(grepp-choose-buffer
), and r
(grepp-rename-buffer-to-last
).)
There are also other buffers that are read-only by default and which it can sometimes be useful to use C-x C-q
and then edit them, in particular (IMHO), *Messages*
, *Help*
, and *Colors*
(from M-x list-colors-display
). Info used to even have a command that lets you edit the current node.
Unfortunately (IMHO), Emacs has generally moved away from such use, making it harder. For example, *Help*
and *Messages*
buffers now defined keys in their respective modes, which means that to edit them normally you need to either (1) change to another mode or (2) use C-q
to be able to insert certain characters.