Search and replace

Published: Wednesday, Dec 26, 2007 Last modified: Saturday, Mar 23, 2024

I always forget %s From vimtutor: 4. To substitute new for the first old on a line type :s/old/new To substitute new for all ‘old’s on a line type :s/old/new/g To substitute phrases between two line #’s type :#,#s/old/new/g To substitute all occurrences in the file type :%s/old/new/g To ask for confirmation each time add ‘c’ :%s/old/new/gc