Vim
A noncomprehensive compilation of my most frequently used commands in Vim.
Cursor Movement
Basic Movement
h- Leftl- Rightk- Upj- Down
Word movement
w- Go to beginning of next worde- Go to end of current/next wordB- Go back to beginning of last word
Line movement
0- Go to beginning of line$- Go to end of line
Page movement
h- Move cursor to top of page-
m- Move cursor to middle of page -L- Move cursor to bottom (low) of page g- jump to end of file-
gg- Jump to beginning of file }- jump to next paragraph (or function/block, when editing code){- jump to previous paragraph (or function/block, when editing code)
Ctrl+[key] movement
Ctrl+e- move screen down one line (without moving cursor)Ctrl+y- move screen up one line (without moving cursor)Ctrl+b- move screen up one page (cursor to last line)Ctrl+f- move screen down one page (cursor to first line)Ctrl+d- move cursor and screen down 1/2 pageCtrl+u- move cursor and screen up 1/2 page
Text editing
Insert text
i- Insert modeo- Insert new line below cursorO- Insert new line before cursorA- Insert at end of current line
Deleting words
Note: You can enter view mode (v ) to highlight, delete, cut, and paste multiple lines at once
x- Delete character under cursordw- Delete word over cursor.- When used afterdwdeletes the next word as welldd- Delete entire lineD- Delete from cursor to end of line
Undo/Redo
u- Undo last change2u- Undo last two changesCtrl-r- Redo changes
Text replacement
r- replace a single character.-
R- replace more than one character, untilescis pressed. cc- change (replace) entire linec$/C- change (replace) to the end of the lineciw- change (replace) entire wordcw/ce- change (replace) to the end of the word
Cut and Paste
Yanking (copy)
yy- yank (copy) a line2yy- yank (copy) 2 linesyw- yank the characters of the word from the cursor position to the start of the next wordyiw- yank (copy) word under the cursoryaw- yank (copy) word under the cursor and the space after or before it-
y$/Y- yank (copy) to end of line d- Cut lineP- Paste before cursorp- Paste after cursor
Selection
ggVG- Select all text in file