Find each occurrence of 'old_string' (in all lines), and replace it with 'new_string'.
Find each occurrence of 'old_string' (in the current line only), and replace it with 'new_string'.
Change each 'old_string' to 'new_string', but ask for confirmation first.
Change only whole words exactly matching 'old_string' to 'new_string'; ask for confirmation.
Change each 'old_string' (case insensitive) to 'new_string'; ask for confirmation.
This may be wanted after using :set noignorecase to make searches case sensitive (the default).
Change each 'old_string' (case sensitive) to 'new_string'; ask for confirmation.
This may be wanted after using :set ignorecase to make searches case insensitive.
The g flag means global – each occurrence in the line is changed, rather than just the first. This tip assumes the default setting for the 'gdefault' and 'edcompatible' option (off), which requires that the g flag be included in %s///g to perform a global substitute. Using :set gdefault creates confusion because then %s/// is global, whereas %s///g is not (that is, g reverses its meaning).
When using the c flag, you need to confirm for each match what to do. Vim will output something like: replace with old_stringnew_string (y/n/a/q/l/^E/^Y)? (where old_stringnew_string is the replacement part of the :s/.../.../ command. You can type y which means to substitute this match, n to skip this match, a to substitute this and all remaining matches ("all" remaining matches), q to quit the command, l to substitute this match and quit (think of "last"), ^E to scroll the screen up by holding the Ctrl key and pressing E and ^Y to scroll the screen down by holding the Ctrl key and pressing Y. However, the last two choices are only available, if your Vim is a normal, big or huge built or the insert_expand feature was enabled at compile time (look for +insert_expand in the output of :version).
Also when using the c flag, Vim will jump to the first match it finds starting from the top of the buffer and prompt you for confirmation to perform replacement on that match. Vim applies the IncSearch highlight group to the matched text to give you a visual cue as to which match it is operating on (set to reverse by default for all three term types as of Vim 7.3). Additionally, if more than one match is found and you have search highlighting enabled with :set hlsearch, Vim highlights the remaining matches with the Search highlight group. If you do use search highlighting, you should make sure that these two highlight groups are visually distinct or you won't be able to easily tell which match Vim is prompting you to substitute.