=============================
help
=============================
PREPEND
Visual mode commands v_
Insert mode commands i_
Command-line commands :
Command-line editing c_
Options ' // :help 'textwidth'
=============================
editing
=============================
:g+//+s/foobar/barfoo/g // g[lobal]默认作用范围是整个文件
:g/./,/^$/join
!5Gsort<Enter>
!{motion}{filter}
!!{filter}
set virtualedit=all
set virtualedit=
=============================
motion
=============================
:map <Space> W
g前缀使命令不是linewise的,常在wrap时和原命令有所区别
; Repeat latest f, t, F or T [count] times.
, Repeat latest f, t, F or T in opposite direction [count] times.
word WORD w W
sentences ( )
paragraph { }
section ]] ][ [[ [] // 函数"{"须在第一列
]} [{ ]) [( ]/ [/
// Text object selection
// can only be used while in Visual mode or after an operator
The commands that start with "a" select "a"n object including white space, the
commands starting with "i" select an "inner" object without white space, or
just the white space.
aw aW as ap a] a[ a) a( a> a< a} a{ // s for sentence && p for paragraph
iw iW is ip i] i[ i) i( i> i< i} i{ // excluding ] [ ) ( > < } {
:set guioptions+=b // 显示滚动条
ze when 'wrap' off scroll horizontally to position the cursor at the end (right side) of the screen.
zh when 'wrap' off scroll screen N characters to the right.
zl when 'wrap' off scroll screen N characters to the left.
zs when 'wrap' off scroll horizontally to position the cursor at the start (left side) of the screen.
=============================
motion-II
=============================
CTRL-O Go to [count] Older cursor position in jump list (not a motion command).
CTRL-I Go to [count] newer cursor position in jump list (not a motion command).
=============================
programming
=============================
:tags // 显示tag stack
:tag {tagname} // 缺省时至stack的top
CTRL-]
:ptag tagname // preview
CTRL-W }
:pclose
:pedit
:psearch
:stag tagname
CTRL-W ]
CTRL-T
:set tags=./tags,./../tags,./*/tags
:set tags=./*/tags
:!ctags -R *
:tnext
:tselect tagname
:tag /block 再按tab补齐
[i // 第一个匹配项
[I // [<Tab> 跳转到[I找到的第一条匹配项
]I // start at the current cursor position
[D // 宏定义
:set path+=d:/mingw/include/*
:checkpath
=============================
text formatting
=============================
:set cindent shiftwidth=4
gg=G
:set textwidth=80
<CTRL-V> // <CTRL-Q> for Windows
Istring<Esc>
cstring<Esc>
:center // :{range}center [width]
:right
=============================
map command autocmd
=============================
:omap <F7> a{
:map <F3> oDate: <Esc>:read !date<CR>kJ
:command -nargs=* DoIt :call AFunction(<f-args>)
:autocmd [group] {events} {file_pattern} [nested] {command}
:augroup cprograms
: autocmd BufReadPost *.c,*.h :set sw=4 sts=4
: autocmd BufReadPost *.cpp :set sw=3 sts=3
:augroup END
:autocmd! cprograms //删除
=============================
vim-script
=============================
b:name buffer variable
w:name window variable
g:name global variable (also in a function)
v:name variable predefined by Vim
s:name script variable
l:name local variable
a:name function argument
$NAME environment variable
&name option
@r register
:execute "tag " . tag_name // . for cancatenate
---> :tag tag_name
:normal gg=G
:execute "normal " . normal_commands
:execute "normal Inew text /<Esc>"
=============================
useful links for VIM scripts
=============================
c.vim http://vim.sourceforge.net/scripts/script.php?script_id=213
-------
Setting
-------
see doc
-------
Usage
-------
<A-F9> save and compile
<F9> link
<C-F9> run
taglist.vim http://vim.sourceforge.net/scripts/script.php?script_id=273
-------
Notes
-------
noremap <silent> <F11> <Esc><Esc>:Tlist<CR>
inoremap <silent> <F11> <Esc><Esc>:Tlist<CR>
-------
Usage
-------
<CR> Jump to the location where the tag under cursor is
defined.
o Jump to the location where the tag under cursor is
defined in a new window.
p Display the tag definition in the file window and
keep the cursor in the taglist window itself.
<Space> Display the prototype of the tag under the cursor.
u Update the tags listed in the taglist window
s Change the sort order of the tags (by name or by order)
d Remove the tags for the file under the cursor
x Zoom-in or Zoom-out the taglist window
+ Open a fold
- Close a fold
* Open all folds
= Close all folds
[[ Jump to the beginning of the previous file
<Backspace> Jump to the beginning of the previous file
]] Jump to the beginning of the next file
<Tab> Jump to the beginning of the next file
EnhCommentify.vim http://vim.sourceforge.net/scripts/script.php?script_id=23
-------
Setting
-------
let g:EnhCommentifyRespectIndent = 'yes'
let g:EnhCommentifyPretty = 'yes'
let g:EnhCommentifyAlignRight = 'yes'
-------
Usage
-------
/x /c
bufexplorer.zip http://vim.sourceforge.net/scripts/script.php?script_id=42
-------
Notes
-------
Needed by winmanager
-------
Usage
-------
/be /bs
winmanager http://vim.sourceforge.net/scripts/script.php?script_id=95
-------
Notes
-------
noremap <silent> <F4> <Esc><Esc>:WMToggle<CR>
inoremap <silent> <F4> <Esc><Esc>:WMToggle<CR>
-------
Usage
-------
:WManager :WMClose :WMToggle
1: File Explorer Area
<tab> : open the file or directory in a new window in the FileEditing area.
c : change the pwd to the directory currently displayed
C : change the currently displayed directory to pwd (converse of c)
s : select sort field (size, date, name)
r : reverse direction of sort
R : rename file
D : delete file
- : move up one level
cppcomplete http://vim.sourceforge.net/scripts/script.php?script_id=527
-------
Notes
-------
default mapping of <F9> conflicts with c.vim
<F8> <F9> --> <F7> <F8>
-------
Usage
-------
<A-j> <A-l> <F7> <F8> <F5>
a.vim http://vim.sourceforge.net/scripts/script.php?script_id=31
-------
Usage
-------
:A :AS :AV
borland.vim http://vim.sourceforge.net/scripts/script.php?script_id=92
-------
Usage
-------
:colorscheme borland
xmledit http://vim.sourceforge.net/scripts/script.php?script_id=301
cvsmenu.vim http://vim.sourceforge.net/scripts/script.php?script_id=58
project.tar.gz http://vim.sourceforge.net/scripts/script.php?script_id=69
grep.vim http://vim.sourceforge.net/scripts/script.php?script_id=311
--------------------------------------------------
摘录自:
VIM USER MANUAL
VIM 手册中文版 by ZhaoRuFei