Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Jul 24 '11 at 10:08

This question came from our site for professional and enthusiast programmers.

It's certainly the default behaviour. – phils Jul 23 '11 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. – Nicholas Riley Jul 23 '11 at 21:06
true, I see it afterwards, but I would like to have it while I write. – stefano Jul 23 '11 at 21:18

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.