How the substitution works

The command below replaces foo with bar throughout the current buffer, asking for confirmation at each match. Press y to accept, n to skip, a to accept remaining matches, or q to stop. Inspect the changes before saving; use u to undo an unwanted edit. The search pattern is a regular expression, not necessarily literal text.
Original article (2013)
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.
