vim replace words in line code example Example 1: vim replace command :%s/foo/bar/g Example 2: vim replace between lines :5,12s/foo/bar/g