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
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
f / Ffind char forward/backward
t / Tuntil char forward/backward
; / ,f/t repeat / reverse
:%s/a/b/g replace in whole file
:%s/a/b/gcreplace in whole file (confirm)
:%s/\Ca/b/gcase-sensitive match
:s/a/b/greplace in current line

operate

keydescription
ddelete
cchange
yyank
=format

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
xdelete character (forward / backward)
rreplace single char
dddelete line
ccchange line
Cchange to end of line
yyyank line
p / Ppaste (after / before cursor)
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 :'<,'>
oswitch to other end of selection

jump list

KeyDescription
Ctrl-oJump back (older location)
Ctrl-iJump forward (newer location)
``Jump to previous position
gdJump to definition
grJump to references
gIJump to implementions
gyJump to type definition

:jumps to view current jump list

change list

KeyDescription
g;Older change
g,Newer change
giJump to last insert
`.Jump to last edit

:changes to view current change list

mark

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

register

keydescription
"ayyyank to register
"appaste register
:regshow registers

:reg to view registers

undo redo

keydescription
uundo
Ctrl-rredo

macro

keydescription
qastart recording
qstop recording
@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
zj / zkjump to next/prev fold
zzscroll to center screen
ztscroll to top
zbscroll to 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
:wasave all
:xasave all and quit
:q!force 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
:%!cmdreplace buffer with shell output
:!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 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