VIM Tutor Cheatsheet


  • 2013-10-01
  • Reference Card of build-in vim tutor
  • #vim
  • #cli

Lesson 1

  • Rule: Operator [Count] Movement
Keys Action
hjkl cursor movement
:q! quit without saving
Esc, ^C normal mode
x delete sign under cursor
i insert before cursor
a append after cursor
A append at end of line
vim {file} open {file} in terminal
:wq write and quit

Lesson 2

Keys Action
dw delete word
d$ delete till end of line
de delete till end of word
w next word (begin of word)
e next word (end of word)
b word backward (begin of word)
0, $ begin, end of line
d2w delete two words
dd delete line
d2d delete 2 lines into register
u undo last change
U restore origion of line
^R reundo to newest change

Lesson 3

Keys Action
p paste deleted text after cur
r{chr} replace cur with {chr}
ce{str} change to end of word
c${str} change to end of line

Lesson 4

Keys Action
^G show line pos and file stats
gg, G go to first, last line
[#]gg, [#]G go to line #
+, - next, prev line
gt, gT next, prev tab
/{str}, ?{str} search forward, backward
n, N search next, prev
^O, ^I go backward, go forward
% find other bracket
:s/{str}/{new} substitute {str} by {new}
:s/{str}/{new}/g subst global at line
:#,#s/{str}/{new}/g subst in #,# range of lines
:%s/{str}/{new}/g subst global in file
:%s/{str}/{new}/gc subst global in file with prompt

Lesson 5

Keys Action
:!{cmd} execute shell command
:!ls list directory
:!rm {file} remove file
:w {newfile} write new file
v visual mode
v ... :w {newfile} write marked to new file
:r {file} read and add text of file
:r !ls read and add command output

Lesson 6

Keys Action
o, O open new line beneath, above cur
R replace mode (following text)
yw copy word
v ... y yank (copy) marked text to register
p paste from register
/{str}\c search with ignore case
:set ic, :set noic ignore case on/off
:set hls, :set nohls highlightsearch on/off

Lesson 7

Keys Action
:help {cmd} search help
:help insert-index insert mode index
:help user-manual user manual
:help vimrc-intro vimrc help
^W ^W jump between windows
:q quit help
:e $M <Tab> edit ~/.vimrc
:helptags ~/.vim/doc update help tags

Scrolling

Keys Action
^E, ^Y scroll down, up (1 line, n lines)
^D, ^U scroll down, up (half window)
^F, ^B pages forward, backward
zt, zz, zb redraw, current line at top, center, bottom of window