* Beginner trouble with regexp matching
@ 2011-10-29 14:22 Marko Vojinovic
2011-10-29 14:25 ` Jai Dayal
0 siblings, 1 reply; 4+ messages in thread
From: Marko Vojinovic @ 2011-10-29 14:22 UTC (permalink / raw)
To: help-gnu-emacs
Hi foks! :-)
Sorry if this question is maybe too trivial, but google wasn't my friend
today. :-(
I am editing a TeX file, and I want to search for "\begin{equation} " (with the
blank space at the end and without quotes), and to add the newline at the end
instead of the blank space. So the obvious way to do it appeared to be to
perform a regexp replacing from
\\begin{equation}
(which finishes with a space) to
\\begin{equation}\n
However, this doesn't work --- Emacs correctly matches the first string, but
fails to replace it with the second, with an error "Invalid use of `\' in
replacement text".
This is my very first try to use regular expressions for search&replace, and I
am still learning. What am I doing wrong?
TIA, :-)
Marko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Beginner trouble with regexp matching
2011-10-29 14:22 Beginner trouble with regexp matching Marko Vojinovic
@ 2011-10-29 14:25 ` Jai Dayal
2011-10-29 14:41 ` Marko Vojinovic
0 siblings, 1 reply; 4+ messages in thread
From: Jai Dayal @ 2011-10-29 14:25 UTC (permalink / raw)
To: Marko Vojinovic; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1108 bytes --]
New lines with replace-string in emacs are a little bit..... random.
M-x replace-string then type \\begin{equation}
then, instead of typing \n, use the key stroke C-q C-j
That should enter the newline as emacs knows it.
On Sat, Oct 29, 2011 at 10:22 AM, Marko Vojinovic <vvmarko@gmail.com> wrote:
>
> Hi foks! :-)
>
> Sorry if this question is maybe too trivial, but google wasn't my friend
> today. :-(
>
> I am editing a TeX file, and I want to search for "\begin{equation} " (with
> the
> blank space at the end and without quotes), and to add the newline at the
> end
> instead of the blank space. So the obvious way to do it appeared to be to
> perform a regexp replacing from
>
> \\begin{equation}
>
> (which finishes with a space) to
>
> \\begin{equation}\n
>
> However, this doesn't work --- Emacs correctly matches the first string,
> but
> fails to replace it with the second, with an error "Invalid use of `\' in
> replacement text".
>
> This is my very first try to use regular expressions for search&replace,
> and I
> am still learning. What am I doing wrong?
>
> TIA, :-)
> Marko
>
>
>
[-- Attachment #2: Type: text/html, Size: 1515 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Beginner trouble with regexp matching
2011-10-29 14:25 ` Jai Dayal
@ 2011-10-29 14:41 ` Marko Vojinovic
2011-10-29 15:00 ` Drew Adams
0 siblings, 1 reply; 4+ messages in thread
From: Marko Vojinovic @ 2011-10-29 14:41 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday 29 October 2011 15:25:36 Jai Dayal wrote:
> New lines with replace-string in emacs are a little bit..... random.
>
> M-x replace-string then type \\begin{equation}
> then, instead of typing \n, use the key stroke C-q C-j
>
> That should enter the newline as emacs knows it.
Great, it works! Thanks! :-) I didn't even need to use regexp for matching,
ordinary string replace did the job... ;-)
Btw, is there some table which tells what should I type in Emacs to put in
such nontrivial characters (newline, carriage return, backspace, tab, etc...)?
Best, :-)
Marko
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Beginner trouble with regexp matching
2011-10-29 14:41 ` Marko Vojinovic
@ 2011-10-29 15:00 ` Drew Adams
0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2011-10-29 15:00 UTC (permalink / raw)
To: 'Marko Vojinovic', help-gnu-emacs
> is there some table which tells what should I type in
> Emacs to put in such nontrivial characters (newline,
> carriage return, backspace, tab, etc...)?
Depends on the mode. In some modes such chars are self-inserting.
But you can always quote to insert any character, with `C-q': See this node of
the Emacs manual: (emacs) `Inserting Text'. (See also these nodes: `Minibuffer
Edit', `International Chars', `Indentation Commands', `Pages', `TeX Editing',
and `Init Non-ASCII'.)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-29 15:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-29 14:22 Beginner trouble with regexp matching Marko Vojinovic
2011-10-29 14:25 ` Jai Dayal
2011-10-29 14:41 ` Marko Vojinovic
2011-10-29 15:00 ` Drew Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).