How do you replace inside a replace?
I know you can get the current word under the cursor into the replace, but I want to perform a replace on it before having it as the output.
For example:
- Having a document that has passed through the clbuttic filter and replacing words that you know have been affected for the worse, such as deinstitutionalization (Hint: Consbreastution of the United States of America). The file also has some words that are properly replaced.
- Changing
oto0in Wooloomooloo (and only for that word) throughout a document
A real world example (from my vim history) is being in a Latex document and running
%s/\\begin{table}\[h\]/\\begin{table}\[H\]/c
where I am duplicating the string just to get a minor change.
Replacing o to 0 is straightforward:
Perhaps you want to know how to apply it to a (visual) selection?
Edit Likely what you want (see comments)
What this does:
[Wolm]\+matches sequences consisting of justW,o,l,m\<[Wolm]\+\>matches (independent) words of the same (so, Wooloomooloo, ormooW,Wlomowould all match, but notamooletc).\zsmarks the begin of the match for replace,\zethe end\=substitute(submatch(0), 'o', '0', 'g')replaces the match (between\zsand\ze) but subsituting0foroYou can start from this pattern
[Wolm]\+with your actual target\zs...\zeso you can reduce matches\cin the front of the pattern to enable case-insensitive matching