Tip Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.

Tip Run vimtutor in a terminal to learn the first Vim commands.

Editing

r - replace a single character

- replace a single character J - join line below to the current one with one space in between

- join line below to the current one with one space in between gJ - join line below to the current one without space in between

- join line below to the current one without space in between gwip - reflow paragraph

- reflow paragraph g~ - switch case up to motion

- switch case up to motion gu - change to lowercase up to motion

- change to lowercase up to motion gU - change to uppercase up to motion

- change to uppercase up to motion cc - change (replace) entire line

- change (replace) entire line C - change (replace) to the end of the line

- change (replace) to the end of the line c$ - change (replace) to the end of the line

- change (replace) to the end of the line ciw - change (replace) entire word

- change (replace) entire word cw - change (replace) to the end of the word

- change (replace) to the end of the word s - delete character and substitute text

- delete character and substitute text S - delete line and substitute text (same as cc)

- delete line and substitute text (same as cc) xp - transpose two letters (delete and paste)

- transpose two letters (delete and paste) u - undo

- undo U - restore (undo) last changed line

- restore (undo) last changed line Ctrl + r - redo

+ - redo . - repeat last command

Marking text (visual mode)

v - start visual mode, mark lines, then do a command (like y-yank)

- start visual mode, mark lines, then do a command (like y-yank) V - start linewise visual mode

- start linewise visual mode o - move to other end of marked area

- move to other end of marked area Ctrl + v - start visual block mode

+ - start visual block mode O - move to other corner of block

- move to other corner of block aw - mark a word

- mark a word ab - a block with ()

- a block with () aB - a block with {}

- a block with {} at - a block with <> tags

- a block with <> tags ib - inner block with ()

- inner block with () iB - inner block with {}

- inner block with {} it - inner block with <> tags

- inner block with <> tags Esc - exit visual mode

Tip Instead of b or B one can also use ( or { respectively.

Visual commands

> - shift text right

- shift text right < - shift text left

- shift text left y - yank (copy) marked text

- yank (copy) marked text d - delete marked text

- delete marked text ~ - switch case

- switch case u - change marked text to lowercase

- change marked text to lowercase U - change marked text to uppercase

Registers

:reg[isters] - show registers content

- show registers content "xy - yank into register x

- yank into register x "xp - paste contents of register x

- paste contents of register x "+y - yank into the system clipboard register

- yank into the system clipboard register "+p - paste from the system clipboard register

Tip Registers are being stored in ~/.viminfo, and will be loaded again on next restart of vim.

Tip Special registers: Special registers: 0 - last yank

" - unnamed register, last delete or yank

% - current file name

# - alternate file name

* - clipboard contents (X11 primary)

+ - clipboard contents (X11 clipboard)

/ - last search pattern

: - last command-line

. - last inserted text

- - last small (less than a line) delete

= - expression register

_ - black hole register



Marks and positions

:marks - list of marks

- list of marks ma - set current position for mark A

- set current position for mark A `a - jump to position of mark A

- jump to position of mark A y`a - yank text to position of mark A

- yank text to position of mark A `0 - go to the position where Vim was previously exited

- go to the position where Vim was previously exited `" - go to the position when last editing this file

- go to the position when last editing this file `. - go to the position of the last change in this file

- go to the position of the last change in this file `` - go to the position before the last jump

- go to the position before the last jump :ju[mps] - list of jumps

- list of jumps Ctrl + i - go to newer position in jump list

+ - go to newer position in jump list Ctrl + o - go to older position in jump list

+ - go to older position in jump list :changes - list of changes

- list of changes g, - go to newer position in change list

- go to newer position in change list g; - go to older position in change list

- go to older position in change list Ctrl + ] - jump to the tag under cursor