Substitute¶
Resources¶
Substitution Flags¶
" the 'n' flag is handy if you need to do a dry run before actually
" substituting
:s/old/new/gn " n returns the number of substitution that will be made
:%&g " Repeat (on entire file) last substitution without flags, ie,
" will replace 'old' with 'new'
:s/old/new/gc " ask for confirmation
More on repeat last substitution here.
Substitute only in visual block¶
" first make visual selection
" then :s
" which will expand to :'<,'>
" replace text in visual block using \%V
:'<,'>s/\%Vfoo/bar/g