Vim
Movement
w start of next word, W to after next white-space character, b start of previous word, e end of next word. 0 begining of the line, $ end of the line. I Insert text at begining of the line, A Append text at the end of the line gg go to top first line of file, G go to last line. H go to first line in screen, M go to middle line, L go to last line in screen. :set number In normal mode, go to particular line number. Ctrl-y Moves screen up one line Ctrl-e Moves screen down one line Ctrl-u Moves cursor & screen up half page Ctrl-d Moves cursor & screen down half page Ctrl-b Moves screen up full page & cursor to last line Ctrl-f Moves screen up full page & cursor to first line ( Move forward one sentence, ) Move backward one sentence { Move forward one paragraph, } Move backward one paragraph zz move current line to middle of screen zt move current line to top zb move current line to bottom f<character> move to next , F<character> move to previous character ; to repeat operation, , to repeat operation in opposite direction
Inset text in multi-line
Ctrl-V to enter visual mode. - Select the lines of text to edit.
Shift-i to insert start of all lines, Shift-a to append at the end of all lines. Esc.
Change to all UPPERCASE or lowercase
- Highlight lines
Shift+u to change all to UPPERCASE or u to change to lowercase
Copy / Cut / Paste
- Move cursor to starting character.
v to select character, or V to select whole line. - Move cursor to end character.
d delete/cut, or y yank/copy. - Move to where to paste
p to paste after cursor, or P paste before cursor.
yy or Y yank current line y$ yank to end of line yiw yank current word yaw yank current word + whitespace ytx yank to character x (before x) yfx yank to character x (including x)
Undo / Redo
u undo last change. U undo all changes in a line or restore Line. Ctrl-R or :redo redo to reverse an undo. 4u undo last 4 changes. 4Ctrl-R redo last 4 undos. . repeat last command.
Search
/foo search for "foo"
Esc to cancel and Enter to search n to search forward and N to search backwords
- In normal mode,
* search forward for the word cursor is on, # search backwards.
Search / Replace
:%s/foo/bar/g find "foo" and replace with "bar" in all lines :s/foo/bar/g find "foo" and replace with "bar" in current line
- Cursor to tag
Ctrl-V to enter visual mode.
at to highlight matching tags including content. it to highlight only content.
o to toggle between start and end.
cs'" to change surrunding ' to ". cst<div> change surrounding tag to ds' to delete surrunding '`' ysaptli> to surround a paragrpah with an <li> tag (ys{motion}{char}) - Highlight text and
S{char or tag} to surround text