I can't believe I've never needed to do this before, but I was struggling with a dumb problem a little while ago. I had a file open in Emacs and it contained a bunch of key/value pairs separated by, what else, the web's favorite: &
To make this more readable I wanted to put each pair on its own line. So I needed to replace all instances of & with newline (or the equivalent of hitting the 'enter' key).
So I did what any emacs user would do:
I typed '&' and hit return. I was then prompted for the replacement string.
If I hit enter, it'll assume I want to replace it with nothing--essentially removing the '&' characters. That's not right.
But what can I use?
Here's what I tried:
- C-q [enter]
- about four other things I've already forgotten
Then I tried a few searches that led me no closer to a solution. So I turned to our internal mailing list for Emacs users. [You know you have a lot of software engineers when you can justify an internal mailing list for Emacs. Or VIM. We've got one for them too.]
The answer, it turns out, is: C-q C-j.
That's right, Control-J is the way to tell emacs to stick in a newline. In retrospect that makes a lot of sense.
Now if I ever forget again, I can just search my own web site and hopefully find this in the future.
Posted by jzawodn at April 13, 2007 01:24 PM