[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regexp/emacs selective replace
From: |
Xah Lee |
Subject: |
Re: regexp/emacs selective replace |
Date: |
Thu, 26 Nov 2009 11:20:34 -0800 (PST) |
User-agent: |
G2/1.0 |
On Nov 23, 5:41 am, m121212 <m121...@mailinator.com> wrote:
> Hi,
>
> I have a tricky problem that I'm not sure how to solve. I have a latex
> document with several figure environments that look like this:
>
> \begin{figure}
> \includegraphics{blah.ps}
> \end{figure}
>
> but need to look like this:
>
> \begin{figure}
> \begin{center} \includegraphics{blah.ps} \end{center}
> \end{figure}
>
> Some of the figure environments already have this however, and I don't want
> to end up with something like this:
>
> \begin{figure}
> \begin{center}\begin{center} \includegraphics{blah.ps}
> \end{center}\end{center}
> \end{figure}
This page answers your question exactly:
• Elisp Lesson: Repeated Find Replace
http://xahlee.org/emacs/elisp_repeat_replace.html
if you prefer emacs to ask you for each case, perhaps just to be sure
your regex didn't find a bad match, see:
• Lisp Lesson: Regex Replace with a Function
http://xahlee.org/emacs/lisp_regex_replace_func.html
> Any ideas? Also, is there a way Emacs can just wrap any selection with
> custom, predefined tags?
(defun wrap-markup ()
"Insert a markup <b></b> around a region."
(interactive)
(goto-char (region-end)) (insert "</b>")
(goto-char (region-beginning)) (insert "<b>")
)
the above is from a collection of simple elisp examples at
• Emacs Lisp Examples
http://xahlee.org/emacs/elisp_examples.html
Xah
∑ http://xahlee.org/
☄
Re: regexp/emacs selective replace,
Xah Lee <=