vim search replace pattern code example Example 1: search and replace vim :%s/foo/bar/g Example 2: search and replace vim :6,10s///g | 14,18&&