Search and Replace in VIM

You can search and replace easily in VIM using this way

:%s/foo/bar/gc

Always have confirmation first, if you want to replace all, can choose ‘a’ after the search.