Replacing text in the vim editor

I always forgot how to replace text in the VIM editor, maybe it is because I need to use more VIM.

To replace a string in all file use:


Where foo is the string that will be replaced by bar.

To replace only in current line: