1.vim自动补全
在配置文件中加入以下内容即可:
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
"inoremap < <><ESC>i
inoremap " ""<ESC>i
inoremap ' ''<ESC>i
2.快速选择{}两个大括号中间的代码
{
XXXXX
}
大括号里面的代码:光标移到第一个大括号,先按v进入visual模式,然后%就可以选中这一段代码了。
XXXXX
}
大括号里面的代码:光标移到第一个大括号,先按v进入visual模式,然后%就可以选中这一段代码了。
3.输入for按tab,自动补全
solution:安装snipMate插件.
| install details |
| unzip snipMate.zip -d ~/.vim (or equivalent, e.g. $HOME\vimfiles on Windows) Keep in mind this will overwrite any files included with older versions of snipMate, including the default *.snippets files for the included filetypes. If you don't want your snippets overwritten, just name them name them differently than the default snippets, e.g. c-mysnips.snippets. NOTE: remember to add ":filetype plugin on" to your .vimrc, otherwise snippets will not work! This is one of the most common issue new users face when trying snipMate. Remember to run ":helptags ~/.vim/doc" to enable the help. 4.vim移动窗口 你已经分割了一些窗口,但现在的位置不正确。这时,你需要一个命令用于移动窗口。 例如,你已经打开了三个窗口,象这样: +----------------------------------+ |/* file two.c */ | |~ | |~ | |two.c=============================| |/* file three.c */ | |~ | |~ | |three.c===========================| |/* file one.c */ | |~ | |one.c=============================| | | +----------------------------------+ 显然,最后一个窗口应该在最上面。移动到那个窗口 (用 CTRL-W w) 并输入如下命令: > CTRL-W K 这里使用大写的 K。这样窗口将被移到最上面。你可以注意到,这里又用 K 表示向上移 动了。 如果你用的是垂直分割,CTRL-W K 会使当前窗口移动到上面并扩展到整屏的宽度。 假设你的布局如下: +-------------------------------------------+ |/* two.c */ |/* three.c */ |/* one.c */ | |~ |~ |~ | |~ |~ |~ | |~ |~ |~ | |~ |~ |~ | |~ |~ |~ | |two.c=========three.c=========one.c========| | | +-------------------------------------------+ 当你在中间的窗口 (three.c) 中使用 CTRL-W K 后,结果会是: +-------------------------------------------+ |/* three.c */ | |~ | |~ | |three.c====================================| |/* two.c */ |/* one.c */ | |~ |~ | |two.c==================one.c===============| | | +-------------------------------------------+ 还有三个相似的命令 (估计你已经猜出来了): CTRL-W H 把当前窗口移到最左边 CTRL-W J 把当前窗口移到最下边 CTRL-W L 把当前窗口移到最右边 5.gvim是什么? 界面的vim 6.vim如何为特定后缀的文件指定语法高亮 用户可以在自己的home目录下的.vim/syntax/目录下添加自己的*.vim语法配置文件,但是通常很少需要这么做,因为vim自身已经带了大部分程序语言的高亮规则。 有时候我们会遇到一些特殊情况,例如我们需要用php语法去显示.html后缀的文件,一种方法是在打开.html文件后用:set filetype=php命令来指定高亮规则,但是这种方法太过麻烦,每次都需要敲入命令;第二种方式是在$home/.vimrc文件中加入一行au BufNewFile,BufRead *.html set filetype=php来进行指定,通过这个配置之后,遇到.html的文件vim会自动应用php的语法。 例如,对于下面这段文本: <?phpecho "this is a php script";if ( true ){ die();}?>
7.插入模式imap 加入下面这几条命令,在输入时,如果需要左右移动光标,我们也不需要把右手移动到方向间上面去了。 :imap <C-G>l <Right> :imap <C-G>h <Left> :imap <C-G><C-L> <C-Right> :imap <C-G><C-H> <C-Left> :imap <F2> <esc>0i //f2移动到最末尾
:imap <F3> <RIGHT> //f3右移 :imap <F4> <C-O>A //f4末尾
"在多个窗格之间移动 "Smart way to move btw. window "Tab configuration
"Bash like
"comment
在输入模式下按下 <CTRL-G> 再按 l ,光标右移。<C-G> + <C-L> 光标右移一个字,相当于普通模式下的 w 。
|

881

被折叠的 条评论
为什么被折叠?



