global find and replace vim code example Example 1: search and replace vim :%s/foo/bar/g Example 2: global find and replace vi :%s/search_string/replacement_string/g