VIM: Find and Replace

There are a variety of options, but these are what you most probably want:

:%s/foo/bar/g find each occurance of 'foo' and replace it with 'bar' without asking for confirmation
:%s/foo/bar/gc find each occurance of 'foo' and replace it with 'bar' asking for confirmation first
:%s/<foo>/bar/gc find (match exact word only) and replace each occurance of 'foo' with 'bar'
:%s/foo/bar/gci find (case insensitive) and replace each occurance of 'foo' with 'bar'
:%s/foo/bar/gcI find (case sensitive) and replace each occurance of 'foo' with 'bar'

NB: Without the ‘g’ flag, replacement occurs only for the first occurrence in each line.

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *