voidynullness

(mis)adventures in software development...

    
05 July 2011

Emacs search and replace newline shenanigans

Share
Category Programming

I can’t believe I’ve never had to do this before: replace a string of one or more characters in a buffer with a single newline. But how to tell Emacs the replace text is a literal newline? The obvious escape characters like \n don’t work. After googling, turns out the answer is deceptively simple:

      C-q C-j

Not exactly intuitive, but kinda sorta makes sesnse in an Emacsian way. Weird how I’ve never had to do this before, but today I needed to do this twice!


 

Comments