Key combination – several keys pressed together, e.g. Ctrl+AE means Ctrl+Shift+aE.
Key sequence – several keys or combinations pressed gradually, e.g.. Ctrl+wwE means a press of combination Ctrl+w and than a key w.
Working mode – it is displayed bottom right:
■ C – basic command mode, EscE,
■ E – insert mode InsC, iC,
■ V – visual, used for highlighting of text blocks vC/VC,
■ ex – command line ex-mode :C.
Repeat command with typing number n× of repetitions before command, e.g. 5xC deletes 5 chars from cursor position. Option set showcmd shows command sequence in bottom right.
Help: help topic, use Tab for command completion.
Similar commands uses same keys, e.g. fC / FC, tC / TC (see below). The difference is direction or range of operation.
Repeat last: command .C, macro @@C
Undo:uC ≈ undo, redo Ctrl+rC / redo
Set or unset options with set option a set nooption. Alone set displays current options.
Shortening of options:set ignorecase ≈ se ic
Line addressing of ex-commands:
xcommand execute on line x
x,ycommand from x to line y
.,$command from actual position to the end
%command ≈ 1,\$command for whole file
.,+xcomm ≈ xcomm from cursor to next x lines
.,$–x from current position to x. line from the end
/pattern1/,/pattern2/ from the first occurrence of line with pattern1 to the first pattern2
More ex-commands together:command1 | command2
Comparison of two files: vimdiff file1file2
Edit and save
Edit:edit file
Open new empty file:enew
Insert file to current position:read file
Insert output of system command:read !command
Save/append file:write file / w >> file
Save/append lines n to m:n,mw file / n,mw>> file
Save and quit:wq, enforced wq!
Quit without save:q! ≈ ZQC
Quit and save when file was changed:x ≈ ZZC
Go to file under the cursos:gfC
Change name of current file:f jméno
Insert before/after: char iC / aC, line IC / AC
Insert new line above/below cursor:OC / oC
Rewrite: char rC, word cwC, line ccC, text RC ≈ InsInsC
Delete char/line and continue edit:sC / SC
Moving throught file
Open file on 23rd line: vim file +23
Cursor:→C ≈ lC, ←C ≈ hC, ↑C ≈ kC, ↓C ≈ jC
Paging:Ctrl+fC ≈ PageUpE / Ctrl+bC ≈ PageDownE
Half-paging up/down:Ctrl+uC / Ctrl+dC
Jump to nth line:n ≈ nGC , the last $ ≈ GC
Jump to percentual line position:n%C
Display current line number:Ctrl+gC, set number
Display number of lines:=
Jump to byte position:goto n
Jump in line before char a forward/backward:taC / TaC
Jump in line to char a forward/backward:faC / FaC
Repeat last line search forward/backward:;C / ,C
Go to beggining of next/previous word:wC / bC
Go to end of a word:eC, with interpunction EC
Go to declaration:gdC
Go to begin/end of paragraph:{C / }C, block: [{C / ]}C
Go to begin/end of line:HomeC ≈ ^C / EndC ≈ $C
Go to next/previous sentence:)C / (C
Go to next/previous line:EndC ≈ +C / -C
Go to column: first 0C ≈ |C; nthn|C
Jump to pair bracket:%C
Print position, number of lines and chars, etc.:gCtrl+gC
Marking of position
Insert invisible mark a:maC
Jump to mark a:'aC
Print marks:marks
Erase mark a:delmarks a
Process text from mark a to b:'a,'b příkaz, e.g. 'a,'b !sort will use external command for sort
Deleting, moving and copying of text
Deletion automatically stores text in register (for moving)