How to find and replace in VI?

How to find and replace in VI?

As we all know, using command "/pattern" or "?pattern" in vi/vim will locate the pattern string.
But, how to replace the pattern with another string ??
http://vcd.cosoft.org.cn/
或许你能在这里找到答案
%s/pattern/replacestring/g for whole file
What does the "g" mean here?Global?
Thanks for you reply, and i will try.