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

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

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 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 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 {} ib - inner block with ()

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

- inner block with {} Esc - exit visual mode

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

Registers

:reg - show registers content

- show registers content "xy - yank into register x

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

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

Tip Register 0 contains always the value of the last yank command.

Marks

: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

Macros