links: 010 Vim MOC


:/<search_string>

Find next/previous occurrence

  • Press enter and then n for next occurrence and N for previous occurrence

Clear last search highlighting

  • :noh to turn off highlighting until the next search

Search and replace syntax

:%s/<search_string>/<replace_string>/command_flag
 
:%s/foo/bar/g
## replaces all occurences of foo to bar in a file
 
:%s/foo/bar/gc
## asks on each occurence whether to replace or not
 
:%s/foo/bar/gci
## case insensitive
 
:36,42s/foo/bar/g
## replace all occurences of foo to bar from line 36 to 42

Escape characters in search - Escape forward and backward slashes in Vim findsearch


tags: find , replace, search

source