vim selection replace code example Example 1: vim replace command :%s/foo/bar/g Example 2: vim replace in selection :'<,'>s/foo/bar/g