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