模式
normal
insert
- i insert 前插
- a append 后插
- o open a line below
- I 开头
- A 末尾
- O open a line up
command
- 替换 :% s/java/python/g
- set nu 设置行号
- sp 横分屏 vs 竖分屏
visual
- v
- V 整行
- ctrl + v 块状
vim 手册
vimtutor
插入模式下
ctrl+h 删除上一个字符
ctrl+w 删除上一个单词
ctrl+u 删除当前行光标之前的内容
motions
- hjkl
- w/b move word by word
- W/B move WORD by WORD
- e/ge move to the end of a word
- E/gE
- f(character) find character in line
- F(character)
- t(character) until character in line
- T(character)
- ; / , 继续搜索
- 0 first character of a line
- ^ first non-blank character of a line
- $ end character of a line
- g_ end non-blank character of a line
- { / } move entire paragraphs
- ctrl + d / ctrl + u
- ctrl + f / ctrl + b
- /{pattern} search forward
- ?{pattern} search backward
- n / N next/previous
- ctrl + o go back
- ? without a pattern change the direction
- gg top of a file
- {line}gg
- G end of a file
operators
- u to undo
- ctrl + r to redo
- d delete
- d2w delete two words
- dt; delete until ;
- df; delete until ;(include ;)
- d/hello delete until hello
- diw
- di”/‘/`
- dd delete a complete line
- D delete from the cursor until the end of the line
- c change (combine d and i)
- cc change a complete line
- C change from the cursor until the end of the line
- . repeat change
- y copy
- yw/y1w copy one word
- y$ copy from the cursor until the end of the line
- yy copy a complete line
- p 在当前位置之后
- P 在当前位置之前
text-object
- w word
- s sentence
- p paragraph
- “ quotes special
- ‘ single quote special
- ` backtick special
- () b
- {} B
- []