Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

vim

switch mode

keydescription
iinsert before cursor
Iinsert at line start
aappend after cursor
Aappend at line end
onew line below
Onew line above
vvisual mode
Vvisual line
Ctrl-vvisual block
gvreselect last visual
Rreplace mode
Escnormal mode

move

keydescription
h j k lleft down up right
w / Wnext word / WORD
b / Bprevious word / WORD
e / Enext word / WORD end
ge / gEprev word / WORD end
0first column
^first non-blank
$end of line
ggtop of file
Gbottom of file
%matching pair
{ / }previous / next paragraph

search & replace

keydescription
/patforward search
?patbackward search
n Nnext/prev result
* #search word under cursor
g* g#partial word search
f / Ffind char forward/backward
t / Tuntil char forward/backward
; / ,f/t repeat / reverse
:s/a/b/greplace in current line
:%s/a/b/gcreplace in whole file (confirm)
:%s/\Ca/b/gccase-sensitive match
:%s/\ca/b/gccase-insensitive match

operate

keydescription
ddelete
cchange
yyank
> / <indent / outdent
=format
gu / gUlowercase /uppercase

examples:

keydescription
dwdelete word
ciwchange inner word
yyyank line
dddelete line
ccchange line
d$delete to EOL

text-object

keydescription
iw awinner/a word
i" a"quote
i' a'single quote
i( a(paren
i{ a{braces
i[ a[bracket
it attag
ip apparagraph

例如:

keydescription
ciwchange word
di(delete inside ()
ya"yank around quotes

normal mode

keydescription
x / Xdelete character (forward / backward)
rreplace single char
dddelete line
ccchange line
Cchange to end of line
yyyank line
p / Ppaste (after / before cursor)
~toggle case
Jjoin lines
.repeat last change

insert mode

keydescription
<C-w>delete previous word
<C-u>delete to line start
<C-r>"insert from register
<C-o>execute one normal command

visual mode

keydescription
ddelete
cchange selection (insert mode on all)
yyank
> / <indent / outdent
=auto-indent
r{char}replace all selected with char
I / Ablock insert at start/end of lines
:auto :'<,'>
oswap visual endpoint

jump list / change list

keydescription
Ctrl-ojump back
Ctrl-ijump forward
gdjump to definition
gijump last insert
g;older change
g,newer change
`.jump last edit

mark

keydescription
maset mark
`ajump exact
'ajump line
``previous jump exact
''previous jump line

register

keydescription
"ayyyank to register
"appaste register
:regshow registers

undo redo

keydescription
uundo
Ctrl-rredo

macro

keydescription
qarecord macro
qstop
@aplay macro
@@repeat
10@aplay 10 times

folding / z

keydescription
zatoggle fold
zo / zcopen / close fold
zO / zCrecursive open / close all nested folds
zR / zMopen / close all folds
zzscroll to center screen
ztscroll to top (top)
zbscroll to bottom (bottom)

window / tab

keydescription
<C-w>h/j/k/lsplit nav
<C-w>vvsplit
<C-w>ssplit
<C-w>cclose windows
<C-w>wcycle to next window
gtnext tab
gTprev tab

command mode

files

commanddescription
:wsave
:xsave and quit
:q!force quit
:wasave all
:xasave all and quit
:e fileopen file

global

commanddescription
:g/pat/cmdexecute cmd on matching lines
:v/pat/cmdexecute cmd on non-matching lines
:%norm cmdexecute normal command on all lines
:%!cmdmodify with shell command
:!cmdrun shell command
:r !cmdinsert shell output
:w !sudo tee %save current file as root (classic rescue)

vimrc

syntax on
filetype plugin indent on

set nonumber
set linebreak
set showbreak=+++
set textwidth=100
set showmatch
set ruler
set visualbell
 
set hlsearch
set smartcase
set ignorecase
set incsearch
 
set autoindent
set expandtab
set shiftwidth=4
set softtabstop=4
set smarttab

set undolevels=1000
set backspace=indent,eol,start
if has('win32')
    set clipboard=unnamed
else
    set clipboard=unnamedplus
endif