in command line mode i can run a search and replace
which extracts part of a pattern and uses it in the
output.
is there any way to do this in normal mode?
here is an example:
command line search and replace:
:s/\[\([0-9]*\)\]/<a href="#n\1"><\/a>[\1]/
of course, in normal mode i can search for
/\[[0-9]*\]
repeatedly with "N", and examine each stop to see if
the change should be done, but how do i suck out the
guts of the target so as to stick them into the
replacement?
It sounds like you want to do search and replace with confirmation:
:%s/foo/bar/gc
which will visit each "foo" match in your file and prompt you
regarding whether you want to replace it with "bar".
If the cursor is hard to spot, you can set
:set scrolloff=9999
which will keep the cursor centered in the screen.
As an alternative, you can use macros ("x" in this case):
qxci[<a href="#n^R""></a>[^R"]^[x2F[x
(where ^R is control+R and ^[ is <escape>) and then
@x
the first time and use
@@
subsequent times.
Just a few ideas,
-tim