VI小抄
Move
- h j k l
- Move to file begin
gg
- Move to file end
G
- Move to line 3
:3
Copy & Paste
Search & Replace
Align several lines
- Go to first line and enter Visual Mode by CRTL-v
- Move to the last line and select the lines by SHIFT-v
- Align the lines to have 4 spaces in the left by entering :'<,'>left 4
(You may need enable ":set expandtab" to insert tab by spaces.)
Undo & Redo
New Window & Split Window
Display
- Display line number
:set number
- Set tab stop
:set tabstop=4
- Insert space to tab
:set expandtab (reversely, :set noexpandtab)
- Highlight cursor line and column
:set cursorline
:set cursorcolumn
- Folding with marker
:set foldenable
:set foldmethod=marker
:set foldmarker={{{,}}}
(Then you can wrap the sections with {{{ and }}} to create folders and sub-folders. You can add comments after {{{ to add the folder comment)
Close a folder by zc
Open a folder by zo
Tag
- Generate tag file
ctags --extra=+q -R .
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
- Install taglist (http://vim-taglist.sourceforge.net/installation.html)
- Show tag list
:Tlist
- Go to a tag
:ta class::member
:ta class.member
:ta /disp*
CTRL-] (go to tag)
CTRL-T (go back)
- Set Multiple Tag files
:set tags:=~/a/tags;~/b/tags
:set tags+=/my/path/to/tags
- Set Tag Files Recursively
:set tags=./tags;/.
Cscope
Word Completion
原文地址:https://www.cnblogs.com/frankbadpot/p/1582780.html