Find and replace strings in vim on multiple lines

前端 未结 11 1810
耶瑟儿~
耶瑟儿~ 2020-12-02 03:29

I can do :%s///g for replacing a string across a file, or :s///

11条回答
  •  不思量自难忘°
    2020-12-02 03:54

    Replace All:

    :%s/foo/bar/g
    

    Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.

    For specific lines:

    :6,10s/foo/bar/g
    

    Change each 'foo' to 'bar' for all lines from line 6 to line 10 inclusive.

提交回复
热议问题