-
Notifications
You must be signed in to change notification settings - Fork 0
E. Lynette Rayle edited this page Mar 2, 2022
·
2 revisions
Reference: http://vim.wikia.com/wiki/Search_and_replace
Search current line only. Defaults: first occurrence, case sensitive
:s/pattern/replace/flag
Search all lines. Defaults: first occurrence, case sensitive
:%s/pattern/replace/flag
Search range of lines inclusive. Defaults: first occurrence, case sensitive Example searches line 5-12 inclusive.
:5,12s/pattern/replace/flag search lines 5-12 inclusive
:1,.s/pattern/replace/flag search lines 1-current line inclusive
:.,$s/pattern/replace/flag search lines current line-end of file inclusive
flags:
- g - replace all
- c - ask before replacing
- i - case insensitive
Count number of occurrences of pattern.
:%s/pattern//ng count all occurrences of pattern