vim – Search and replace

#Search for pattern

/pattern

#Search backward for pattern

?pattern

#’Very magic’ pattern: Non-alphanurmic characters are interpreted as special regex symbols(no escaping needed)

\vpattern

#Repeat search in same direction

n

#Repeat search in opposite direction

N

#Replace all old with new throughout file

:%s/old/new/g

#Replace all old with new throughout file with confirmations

:%s/old/new/gc

#Remove highlighting or search matches

:noh

Leave a Reply

Your email address will not be published. Required fields are marked *