how to find all and replace in vim code example Example 1: search and replace vim :%s/foo/bar/g Example 2: vim replace command :%s/foo/bar/g