Say I want to replace all the new lines in my emacs buffer with the character k (wait for the -1, read the rest! :) ). I know I can type M-x replace-string RET C-q C-j RET k. It works fine.

My problem is that the new line character, i.e. ^J is not displayed in the replace query, I just get a new line in the query string. Instead if I try to type C-q C-<another_char> I get ^<another_char>.

As I said, it works fine, but it is annoying, because it is not compact and not easily readable. Is this the default behavior in emacs? Does anybody know how to change it?

  • 1
    It's certainly the default behaviour.
    – phils
    Commented Jul 23, 2011 at 18:36
  • It should show the ^J after you accept the search string, right? At least, mine looks like: Replace string ^J with: so you'll at least see it afterward. Commented Jul 23, 2011 at 21:06
  • true, I see it afterwards, but I would like to have it while I write.
    – stefano
    Commented Jul 23, 2011 at 21:18

1 Answer 1


I don't think Emacs's behavior can be changed in the way you want. Have you thought about using regexp-replace instead? That way you could see your new lines as \n.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .