* Re: AW: replace a textblock in multiple files
[not found] <mailman.7420.1159269539.9609.help-gnu-emacs@gnu.org>
@ 2006-09-26 15:44 ` Mathias Dahl
2006-09-29 0:51 ` B. T. Raven
2006-09-27 3:36 ` Benjamin Rutt
1 sibling, 1 reply; 4+ messages in thread
From: Mathias Dahl @ 2006-09-26 15:44 UTC (permalink / raw)
<C.Strobl@dlr.de> writes:
> 1) i want to work on several subdirectories, not only in one directory
> 2) i want to replace blocks consisting of more than one line.
In dired, navigate one folder "higher" than where you want to start
your replacement. Then insert the directory you want to work with
using C-u i and add an R to the arguments at the prompt. This will add
all files recursively into the dired buffer and you can work with the
files from there.
The Q command should accept multi line blocks as long as you can find
a regexp to do it. If not, maybe you want to write a small helper
elisp function.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: AW: replace a textblock in multiple files
2006-09-26 15:44 ` AW: replace a textblock in multiple files Mathias Dahl
@ 2006-09-29 0:51 ` B. T. Raven
0 siblings, 0 replies; 4+ messages in thread
From: B. T. Raven @ 2006-09-29 0:51 UTC (permalink / raw)
"Mathias Dahl" <brakjoller@gmail.com> wrote in message
news:u8xk6iqel.fsf@gmail.com...
> <C.Strobl@dlr.de> writes:
>
> > 1) i want to work on several subdirectories, not only in one directory
> > 2) i want to replace blocks consisting of more than one line.
>
> In dired, navigate one folder "higher" than where you want to start
> your replacement. Then insert the directory you want to work with
> using C-u i and add an R to the arguments at the prompt. This will add
> all files recursively into the dired buffer and you can work with the
> files from there.
>
> The Q command should accept multi line blocks as long as you can find
> a regexp to do it. If not, maybe you want to write a small helper
> elisp function.
Beautiful! Emacs can do it out of the box without loading any further
resources. Here is what I did combining this problem with the one in the
other thread about replacing text in the html <column_right> block:
C-u [actual numeric argument not needed] C-x d [here modify the ls
switches to make them read -IR as per Mathias] [specify parent of all
sub-directories of interest; files in this parent directory containing
matches to regexp will be processed too.] %g someregexp* Q sameregexp [a
buffer is opened for each file in parent and in all subdirectories
containing match(es) to regexp and the process works exactly as in C-M-%.
* In the block search-replace example you could use: (not tested but I
think the middle pair of escaped parentheses will be interpreted as
grouping rather than as matched substring for later reference by \1 \2)
\(<starttextpattern>\)\(.\|^J\)*?\(<endtextpattern>\) RET
\1<replacementtext>\2 RET ;; search-replace arbitary text bracketed by
start- and endpattern. ^J is input with C-qC-j
[Thanks to Florian Kaufman for this. Now I understand non-greedy operators
better.]
Ed
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: AW: replace a textblock in multiple files
[not found] <mailman.7420.1159269539.9609.help-gnu-emacs@gnu.org>
2006-09-26 15:44 ` AW: replace a textblock in multiple files Mathias Dahl
@ 2006-09-27 3:36 ` Benjamin Rutt
1 sibling, 0 replies; 4+ messages in thread
From: Benjamin Rutt @ 2006-09-27 3:36 UTC (permalink / raw)
<C.Strobl@dlr.de> writes:
> thanks, but maybe my question was too short.
>
> 1) i want to work on several subdirectories, not only in one directory
M-x find-dired RET
then apply my rule as is.
> 2) i want to replace blocks consisting of more than one line.
yes just do a C-q C-j when you want to enter a newline.
--
Benjamin Rutt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: replace a textblock in multiple files
@ 2006-09-26 0:52 Benjamin Rutt
2006-09-26 11:18 ` AW: " C.Strobl
0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Rutt @ 2006-09-26 0:52 UTC (permalink / raw)
<C.Strobl@dlr.de> writes:
> hello all,
> only a short and simple question: whats the best way to replace a
> textblock in multiple files.
> thanks and i hope the question is not to easy
> christian
M-x dired
mark desired files with 'm'
Q
--
Benjamin Rutt
^ permalink raw reply [flat|nested] 4+ messages in thread
* AW: replace a textblock in multiple files
2006-09-26 0:52 Benjamin Rutt
@ 2006-09-26 11:18 ` C.Strobl
0 siblings, 0 replies; 4+ messages in thread
From: C.Strobl @ 2006-09-26 11:18 UTC (permalink / raw)
thanks, but maybe my question was too short.
1) i want to work on several subdirectories, not only in one directory
2) i want to replace blocks consisting of more than one line.
is that possible at all
tanks again
christian
p.s. i know it's always possible with programming elisp. but i want to know if it's possible with simple emacs commands?
> -----Ursprüngliche Nachricht-----
> Von: help-gnu-emacs-bounces+c.strobl=dlr.de@gnu.org
> [mailto:help-gnu-emacs-bounces+c.strobl=dlr.de@gnu.org] Im
> Auftrag von Benjamin Rutt
> Gesendet: Dienstag, 26. September 2006 02:52
> An: help-gnu-emacs@gnu.org
> Betreff: Re: replace a textblock in multiple files
>
> <C.Strobl@dlr.de> writes:
>
> > hello all,
> > only a short and simple question: whats the best way to replace a
> > textblock in multiple files.
> > thanks and i hope the question is not to easy christian
>
> M-x dired
>
> mark desired files with 'm'
>
> Q
> --
> Benjamin Rutt
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-09-29 0:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.7420.1159269539.9609.help-gnu-emacs@gnu.org>
2006-09-26 15:44 ` AW: replace a textblock in multiple files Mathias Dahl
2006-09-29 0:51 ` B. T. Raven
2006-09-27 3:36 ` Benjamin Rutt
2006-09-26 0:52 Benjamin Rutt
2006-09-26 11:18 ` AW: " C.Strobl
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).