vi commond
- commonds of vi all can be used in vim
three modes of vi
- common mode : defaut; return by [esc]
- [10(n) + space] : move 10 char to right
- [+ / -] move down / move up
- [0/$] = [home/end] = move to row start / move to row end
- [H/M/L/G] = move to row1 of screen / rowMiddle of screen / rowEnd of screen / rowEnd of file
- 10G(ng) : move to row10 of this file
- gg : move to row1 of this file
- 10 + enter : move down 10 row
- /cyy : search down ‘cyy’
- n :next down one
- N : next up one
- ?cyy : search up ‘cyy’
- n :next down one
- N : next up one
- u : 撤销 上一步操作 ; ctrl + r : 恢复上一步撤销
[:100,200s/cyc/cyy/g] search from row100 to row200 replace 'cyc' to 'cyy'
[:1,$s/cyc/cyy/g] search from rowOne to rowEnd replace 'cyc' to 'cyy'
[:1,$s/cyc/cyy/gc] search from rowOne to rowEnd replace 'cyc' to 'cyy' by confirm
- x/X : delete to tail / delete to heand
- 10x : delete char10 to tail
- dd : delete hole of one row
- 20dd : delete row20 of down
- d$ : delete here to tail of one row
- d0 : delete here to head of one row
- yy : copy hole of one row
- 10yy : copy row10 of down
- y$ : copy here to tail of one row
- y0 : copy here to head of one row
- p / P : paste to down of here / paste to up of here
- J : join next down row to here row
- 8J : join next down row8(contains here row ) to here row
- ctrl + r : 重复做上一次动作
- . : 重复前一个动作
- edit mode : [i/o/a/r] will come in this mode
- [home/end] = move to row start / move to row end
- commond mode : [ : / ? ] will come in this mode
- [:w] save without quit
- [:w filename] save to another file of new filename
- [:wq] save and quit
- [:q!] quit force
- [:r filename] import text of filename to this file
- [:set nu] set the row number visiable
- [:set nonu] set the row nuber not visiable
- [:set hlsearch] set high light view
- [:set nohlsearch] set no hig light view
- [:set autoindent] set 自动缩排
- [:set noautoindent] set no 自动缩排
commond of vim only
- text select
- v : char select
- V : row select
- ctrl + v : rectangle select
- y : copy ; p : past
- d : delete
- files vim
- :n ] vim next down one file
- :N ] vim next up one file
- :files ] all files in this vim
- :sp ] multi window
- ctrl + w + up/down ] exchange window
- [ctrl + w + q]/ [:q] quit window