19 July 2014

####删除

C+W 在输入模式下,删除单词
C+U 在输入模式下,删除全部单词

###跳转

[[
[{
]}
]]

% : 匹配括号移动,包括 (, {, [. (陈皓注:你需要把光标先移到括号上) 
* 和 #:  匹配光标当前所在的单词,移动光标到下一个(或上一个)匹配单词(*是下一个,#是上一个)

"g_" 到本行最后一个不是blank字符的位置。

"fa" 到下一个为a的字符处,你也可以fs到下一个为s的字符。 

"t,"  到逗号前的第一个字符。逗号可以变成其它字符

"3fa"  在当前行查找第三个出现的a。	

F 和 T →和 f 和 t 一样,只不过是相反方向。

块操作,典型的操作: 0 <C-v> <C-d> I-- [ESC]

^ 行头
<C-v> 开始块操作
<C-d> 向下移动(你也可以使用hjkl来移动光标,或是使用%,或是别的)
"v <C-v> I -- [ESC]"  I 是插入,插入“--”,按ESC键来为每一行生效。

<C-X><C-L>    : Line complete SUPER USEFUL
/<C-R><C-W>   : Pull <cword> onto search/command line

" source $MYVIMRC reloads the saved $MYVIMRC
:nmap <Leader>s :source $MYVIMRC

" opens $MYVIMRC for editing, or use :tabedit $MYVIMRC
:nmap <Leader>v :e $MYVIMRC

" <Leader> is \ by default, so those commands can be invoked by doing \v and \s"

guu     : lowercase line
gUU     : uppercase line
~       : invert case (upper->lower; lower->upper) of current character
gf      : open file name under cursor (SUPER)
ga      : display hex, ascii value of character under cursor
g8      : display hex value of utf-8 character under cursor
ggg?G   : rot13 whole file
xp      : swap next two characters around
CTRL-A,CTRL-X : increment, decrement next number on same line as the cursor
=             : (re)indent the text on the current line or on the area
selected (SUPER)
=%            : (re)indent the current braces { ... }
G=gg          : auto (re)indent entire document

'.       : jump to last modification line (SUPER)
`.       : jump to exact spot in last modification line
<C-O>    : retrace your movements in file (backward)    --powerful
<C-I>    : retrace your movements in file (forward)     --powerful

List registers
:reg     : display contents of all registers
"1p      : paste from register 1

Recording
@@            : repeat

:r !cmd => 从命令行执行cmd并读取输出到当前位置
shift-v选中多行然后 :!cmd => 将选中的行作为cmd的输入并用输出替换(filter模式)
:r!ls                 : reads in output of ls (use dir on Windows)
:r !grep "^ebay" file.txt  : read output of grep
:r!date              : insert date (use  date /T on Windows)
:.!sh                : execute contents of current line in buffer and capture the output
:r url => 读取网络文件内容

gq[NUM][Char] : 当设置 set textwidth=80, 拷贝到vim 的文字不能自动对齐的时候,使用。如 gq5j gq} gqG等等

:set paste => 防止从外部粘贴代码到Vim中时缩进混乱
ctrl-v-shift-i-内容-esc => 在多行前同时插入内容

di", di{, di[, di( => 删除引号和括号中的内容
da", da{, da[, da( => 删除引号括号及其里面的内容
df-字符 => 删除当前位置到下一个字符处的内容

q: 或者 :ctrl-f => 显示执行的历史命令