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