1) modes:
mode | key | description |
General Mode | <ESC> | |
Insert Mode | i | begin at current cursor place |
| a | begin at the following character position |
| A | begin at the end of this line |
| o | get a new line below |
| O | get a new line above |
| ce | remove the following characters of the word the cursor points to |
Replace Mode | R | replace all, r can replacethe current character |
Visual Mode | v | |
Visual BlockMode | Ctrl + v | |
2) General Mode:
2.1) move cursor
) (k)KongMiao
) |
) (h)HeNan -------------- (l)Angeles
) |
) (j)Java
key | description |
w | move cursor forward to the front of the next word |
e | move cursor forward to the tail of the next word |
Nw | move cursor forward N words(to the start of a word |
Ne | move cursor forward N words(to the end of a word |
0 | move cursor to the start of this line |
$ | move cursor to the end of this line |
gg | move cursor to the start of this file |
G | move cursor to the end of this file |
Ctrl+ g | show where the cursor is and the file state |
2.2) delete contents
key | description |
x | delete acharacter |
d2w | delete 2 words |
dw | delete aword(including whitespace) |
de | delete aword(excluding whitespace) |
dd | delete a line |
2dd | delete 2 lines |
J | delete '\n' ofcurrent line |
d$ | delete all the following characters of this line |
2.3) move contents
description | detailed-description | key |
move words/lines | | (deletecontents) + p(paste) |
copy words/lines | copy blocks | v(visual mode) + move cursor + y(yank, copy) + p(paste) |
copy words/lines | copy word | yw(yank word) + p(paste) |
2.4) undo and redo
description | key |
undo | u |
redo(undo undo) | Ctrl +r |
undo alloperations for this line | U |
2.5) search commands
description | key |
search the wordthe cursor points to | Shift+ * |
search forward | /xxxx |
search backward | ?xxxx |
search andignore case once | /xxxx/c |
jump to the nexthit target | n |
jump to theprevious hit target | N |
return to previous | Ctrl + o |
return to next | Ctrl + i |
2.6) customize search rules
description | key |
set ignore case | :setic |
set hlsearch andincsearch | :sethls is |
set no ignorecase | :setnoic |
remove highlightsearch | :setnohlsearch |
ignore caseonce | /xxxx/c |
2.7) help
description | key |
vimdocumentation help | :help |
exit help | ZZ |
enter hyperlink | Ctrl+ ] |
exit hyperlink | Ctrl+ t, Ctrl + o |
shell command | vimtutor |
2.8) shell command related
description | detailed-description | key |
retrive and merge files | retrive contents in file A and insert it to the next line of theposition the cursor points to | :rfileA |
retrive and merge files | retrive result of a commandA execution and insert it to the next line of theposition the cursor points to | :r!commandA |
execute external command | | :!command (shellcommand) |
| write to a specific fileF | :w fileF |
| remove a specific fileF | :rm fileF |
| write the seleted contentsto a specific fileF | v (movecursor) :w fileF |
2.9) visual block insert(useful when annotating source code):
Ctrl + v(enter visual blockmode), I + characters(insert), <ESC>
2.10) vsplit
description | detailed-description | key |
open another fileF | | :vsplitfileF |
switch between windows | | Ctrl+ ww |
equalize window size | | Ctrl+ W, = |
vertical resize window size | specify size | :vertical resize N(pixels) |
| increase/decrease size | :Ctrl+ W, </> |
horizontal resize window size | specify size | :resize N(pixels) |
| increase/decrease size | :Ctrl+ W, +/- N(pixels) |