I am a vim user, and I want to be able to loop over a range of substrings when I am substituting. How can I use some vim magic to go from a set of lines like this:
It's probably going to be much easier to record a macro that can replace the first two, and then use :s for the rest.
The macro might look like /foo^Mcwbar^[. If you're not familiar with macro mode, just hit q, a (the register to store it in) and then the keystrokes /foo .
Now once you've got that macro, do 2@a to replace the first two occurrences in the current buffer and use :s normally to replace the rest.