vim:cheatsheet:search_and_replace
VIM - Cheatsheet - Search and replace
/pattern - search for pattern ?pattern - search backward for pattern \vpattern - 'very magic' pattern: non-alphanumeric characters are interpreted as special regex symbols (no escaping needed) n - repeat search in same direction N - repeat search in opposite direction :%s/old/new/g - replace all old with new throughout file :%s/old/new/gc - replace all old with new throughout file with confirmations :noh[lsearch] - remove highlighting of search matches
Search in multiple files
:vim[grep] /pattern/ {`{file}`} - search for pattern in multiple files
Example
:vim[grep] /foo/ **/*
:cn[ext] - jump to the next match :cp[revious] - jump to the previous match :cope[n] - open a window containing the list of matches :ccl[ose] - close the quickfix window
vim/cheatsheet/search_and_replace.txt · Last modified: 2021/02/16 10:44 by peter