Vim: Searching and replacing

/string - search forward for string
?string - search backward for string
n - next
N - previous, reverse order

:set ignorecase - for case insensitive searches
Don't retype searches, use history:
/ - and hit up arrow
? - and hit up arrow

/the\> - finds words that end with the
/\<the - finds words that begin with the
/\<the\> - finds the as a word
:set hlsearch - set highlight on

Set your highlight colors in search with:
:hi search ctermbg=grey ctermfg=blue

^ and $ are useful for finding the beginnings and ends of lines

If you can't type a very long search, go to the string to search and press *. Now the word will be highlighted

vim +/string file.txt - go to the vim and search for a string in the file and go to that line
:set hlsearch - highlight search
fx - moves to the next instance of x
2fx - moves to the second instance of x
Fx - moves to the previous instance of x

:s/I/you - finds/replaces first instance on current line
:%s/I/you/g - finds/replaces all instances on all lines
:%s/I/you/gc - finds/replaces with confirmation
:%s/I/you/gci - adds case insensivity to the operation
:10,40 s/I/you/g - do operation on lines 10-40
:%s//bar/g - replaces previously searched word (or word under cursor) with bar globally
:%s/foo//g - replaces foo globally with previously searched word (or nothing - just removes word foo)
:%s/I\s/you/g - finds/replaces all I with space - "I " instances on all lines with you

% - substitute on all lines
g - substitute all occurences
c - confirm each operation
i - case insensitive

cc - replace line
cw - replace to end of word, enters insert mode
cW - replace to end of word including special chars
c$ - replace to end of line
c} - replace a paragraph
cG - replace until the end of file
r - replace single character
5r - replace 5 characters with entered character
R - replace until you hit Esc
s - substitute character
5s - substitute 5 characters by removing current ones
S - substitute line