Optimising what @MattObert said:
- y3iw
- /
red dogEnter - c3iwCtrl-r0Esc
- n. etc.
In detail:
- y3iw yanks
philosophical chicken; this is marginally better than y2W because the latter includes a trailing space; the iw part also makes sure the yank still works when you start with the cursor in the middle of the first word, rather than at the beginning - /
red dogEnter finds the firstred dog - c3iw deletes
red dog(again, without the trailing space) and switches to insert mode - Ctrl-r0 pastes from register
0(cf.:h i_CTRL-Rand:h quote0) - Esc switches to normal mode
- n. finds the next
red dogand re-plays the last operation (i.e. replaces it withphilosophical chicken) - repeat n. as needed.
The first trick is that yanks are automatically saved to register 0. The second trick is you can paste registers in insert mode with Ctrl-r.
Other things that would help you:
- turn on line numbers:
:setlocal relativenumber! number!(run it again to turn it off) - same thing as a macro:
nnoremap <silent> <Leader>, :setlocal relativenumber! number!<CR> - use line offsets relative to the cursor line:
:.,+6 s/.../.../ - replace with confirmation:
:%s/red dog/philosophical chicken/gc
Take a look at Drew Neil's Vimcasts for other similar tricks. Also consider posting Vim-related questions to the Vi siteVi site.