In Emacs, I tried to replace a character say ";" with a new line using replace-string and/or replace-regexp.
Below commands are what I have tried.
M-x replace-string ; \n (will replace ";" with 2 characters "\n" )
M-x replace-regex ; \n ( get below error from minibuffer )
Invalid use of `\' in replacement text.
Is there anything wrong using replace-string. Or if there is any other way to do that? Thanks.
From stackoverflow
-
M-x replace-string ; C-q C-j
C-q for
quoted-insert
C-j is a newline.
Cheers!
Joe Casadonte : C-q is really `quote-insert` which quotes the next character.Bryan Oakley : I believe it's actually "quoted" rather than "quote", as in "quoted-insert". At least that's the way it is on version 22.1.jrockway : yes, you're right. fixed.Jonathan Arkell : Whups! Thanks guys -
Don't forget that you can always cut and paste into the minibuffer.
So you can just copy a newline character (or any string) from your buffer, then yank it when prompted for the replacement text.
Lei : It's really a good idea for the characters which I don't know the key bind.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.