gg=G
shift-v
j j j j j:s/foo/bar/g
replaces foo with bar in only the 5 lines you've highlighted.
Wow, that post was actually extremely useful! You'd think after 16 years of using VIM I'd have tried ":help sex" but no.
I love to use the formatting that is included. Set your filetype and syntax correctly, then type:
gg=G
Now your indent preferences, as well as the filetype specific indenting rules are applied to your whole file. Great for getting a piece of code that has horrible standards, just gg=G and you've formatted your file according to your tabstop requirements.
What I just now learned is how it all works.
gg -> Go to the first line of the file.
= -> runs 'equalprg' and if empty, either 'lisp' 'cindent' or 'indentexpr' are run.
G -> Do something from where you are now to the end of the file.
Will not work if you've set equalprg to something else.
"May your future be limited only by your dreams." -- Christa McAuliffe