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