Something I found very useful today:
ITworld.com - Search and replace with vi -- part 1
There is another form of line addressing called global addressing. It is similar to the % (all lines) address, but allows you to limit the search and replace action by specifying certain text that must appear in a line before the search and replace action is applied to it. An example is show below. The syntax shown below would read "for all lines containing `some text', search for `search text' and replace any instances with `replacement text.'"
:g/some text/s/search text/replacement text/
In effect, you are requesting that two strings must be found in a line, but only one of them is to be replaced.