how to search for words in vim code example
Example 1: how to search replace in vim
-- How to search-replace (substitute) in vim --
:(RANGE)s/(SEARCH)/(REPLACE)/(GC)
(RANGE) can be
- Blank for just current line
- "Start, Stop" for line range, e.g. "4,8"
- "%" for whole file
(SEARCH) can be simple text or a regex (see source for details)
(REPLACE) should be obvious...
(GC)
- Appending "g" replaces all occurances, not just the first
- Appending "c" allows vim to confirm each replacement
They can be used together, separate, or not at all
Example 2: vim search for word
# Basic syntax:
/word # To search for the word "word"
# If a match is found, use n and N to navigate to next or previous matches
# Note, special characters like "/" need to be escaped with \. E.g., to
# search for path/to/directory you'd write:
/path\/to\/directory