放在最上面的话

  超爱vim,但是一直没能发挥vim神器的功能,终于,一位大神的横空出世(事实上人家早有了。。。),让我的vim技能点迅速提升,他的帖子写的太好了,转过来,以备不时只需。

  出处http://www.vimer.cn

   注:一般都是在normal模式下,<C-xxx>指按下ctrl键再按后面的那个xxx,<Tab>指按下tab键,类推。

经典系列

VIM-一键编译单个源文件(windows下很疼)
http://www.vimer.cn/2009/10/11.html

把VIM打造成一个真正的IDE(1~3)
http://www.vimer.cn/2009/10/%E6%8A%8Avim%E6%89%93%E9%80%A0%E6%88%90%E4%B8%80%E4%B8%AA%E7%9C%9F%E6%AD%A3%E7%9A%84ide1.html
http://www.vimer.cn/2009/10/%E6%8A%8Avim%E6%89%93%E9%80%A0%E6%88%90%E4%B8%80%E4%B8%AA%E7%9C%9F%E6%AD%A3%E7%9A%84ide2.html
http://www.vimer.cn/2009/10/%E6%8A%8Avim%E6%89%93%E9%80%A0%E6%88%90%E4%B8%80%E4%B8%AA%E7%9C%9F%E6%AD%A3%E7%9A%84ide3.html
更适合面向对象语言使用的显示函数列表插件-tagbar.vim(<F4> 和作者信息那个热键冲突 自己在vimrc里面改下即可)
http://www.vimer.cn/2011/03/%E6%9B%B4%E9%80%82%E5%90%88%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E8%AF%AD%E8%A8%80%E4%BD%BF%E7%94%A8%E7%9A%84%E6%98%BE%E7%A4%BA%E5%87%BD%E6%95%B0%E5%88%97%E8%A1%A8%E6%8F%92%E4%BB%B6-tagbar-vim.html
vim(gvim)添加作者信息插件升级版-更智能,支持更多语言
http://www.vimer.cn/2011/02/vimgvim%E6%B7%BB%E5%8A%A0%E4%BD%9C%E8%80%85%E4%BF%A1%E6%81%AF%E6%8F%92%E4%BB%B6%E5%8D%87%E7%BA%A7%E7%89%88-%E6%9B%B4%E6%99%BA%E8%83%BD%E6%94%AF%E6%8C%81%E6%9B%B4%E5%A4%9A%E8%AF%AD%E8%A8%80.html
用vim在代码文件中自动添加#ifdef,#define,#endif的头文件宏定义(,ha)
http://www.vimer.cn/2010/01/%E7%94%A8vim%E5%9C%A8%E4%BB%A3%E7%A0%81%E6%96%87%E4%BB%B6%E4%B8%AD%E8%87%AA%E5%8A%A8%E6%B7%BB%E5%8A%A0ifdefdefineendif.html
饭前甜点-vim(gvim)自动在cpp文件中添加.h文件包含(normal模式 ,hh)
http://www.vimer.cn/2010/01/%E9%A5%AD%E5%89%8D%E7%94%9C%E7%82%B9-vimgvim%E8%87%AA%E5%8A%A8%E5%9C%A8cpp%E6%96%87%E4%BB%B6%E4%B8%AD%E6%B7%BB%E5%8A%A0-h%E6%96%87%E4%BB%B6%E5%8C%85%E5%90%AB.html

 

自动完成

vim所支持的自动完成详解
http://www.vimer.cn/2010/01/vim%E6%89%80%E6%94%AF%E6%8C%81%E7%9A%84%E8%87%AA%E5%8A%A8%E5%AE%8C%E6%88%90%E8%AF%A6%E8%A7%A3.html

1.关键字补全,按键是:
FORWARD: <C-X><C-N>
BACKWARD: <C-X><C-P>


2.整行补全,按键是:
<C-X><C-L>

3.文件名补全,按键是:
<C-X><C-F>

4.字典补全,按键是(杯具啊,为了这个<C-K>,我把原来的C-K映射都给删掉了):
<C-X><C-K>

5.全能补全,按键是:
<C-X><C-O>
一张Vim(gVim)的使用图~(code_complete.vim for<tab> )
http://www.vimer.cn/2010/03/%E4%B8%80%E5%BC%A0vimgvim%E7%9A%84%E4%BD%BF%E7%94%A8%E5%9B%BE.html


加强VIM对函数体,以及HTML等标签语言的处理

http://www.vimer.cn/2009/10/%E5%8A%A0%E5%BC%BAvim%E5%AF%B9%E5%87%BD%E6%95%B0%E4%BD%93%EF%BC%8C%E4%BB%A5%E5%8F%8Ahtml%E7%AD%89%E6%A0%87%E7%AD%BE%E8%AF%AD%E8%A8%80%E7%9A%84%E5%A4%84%E7%90%86.html

ci[ 删除一对 [] 中的所有字符并进入插入模式
ci( 删除一对 () 中的所有字符并进入插入模式
ci< 删除一对 <> 中的所有字符并进入插入模式
ci{ 删除一对 {} 中的所有字符并进入插入模式
cit 删除一对 HTML/XML 的标签内部的所有字符并进入插入模式

vi[ 选择一对 [] 中的所有字符
vi( 选择一对 () 中的所有字符
vi< 选择一对 <> 中的所有字符
vi{ 选择一对 {} 中的所有字符
vit 选择一对 HTML/XML 的标签内部的所有字符
vi" vi' vi` 选择一对引号字符 ("' 或 `) 中所有字符



正则表达式系列(现在只会简单用法 normal模式下/然后正则表达式)

  正则表达式30分钟入门教程

deerchao.net/tutorials/regex/regex.htm(原文地址 不知道什么情况 貌似需要FQ 下面地址是转过来的 内容一样 经典的东西)
http://www.cnblogs.com/deerchao/archive/2006/08/24/zhengzhe30fengzhongjiaocheng.html


Vim正则表达式查找替换(1-5
http://www.vimer.cn/2009/10/vim%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%9F%A5%E6%89%BE%E6%9B%BF%E6%8D%A2.html
http://www.vimer.cn/2009/11/vim%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%9F%A5%E6%89%BE%E6%9B%BF%E6%8D%A22.html
http://www.vimer.cn/2009/11/vim%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%9F%A5%E6%89%BE%E6%9B%BF%E6%8D%A23-%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86.html
http://www.vimer.cn/2009/11/vimgvim%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%9F%A5%E6%89%BE%E6%9B%BF%E6%8D%A24-%E7%94%9F%E6%88%90%E8%BF%9E%E7%BB%AD%E6%95%B0%E5%AD%97%E6%88%96%E8%A1%8C%E5%8F%B7.html
http://www.vimer.cn/2009/11/vim%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%9F%A5%E6%89%BE%E6%9B%BF%E6%8D%A25-%E7%AD%89%E5%8F%B7%E6%95%B4%E7%90%86%E5%92%8C%E6%8C%87%E5%AE%9A%E5%8C%BA%E5%9F%9F%E6%9F%A5%E6%89%BE%E6%9B%BF.html
http://www.vimer.cn/2009/11/vimgvim%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%9F%A5%E6%89%BE%E6%9B%BF%E6%8D%A25-%E5%8E%8B%E7%BC%A9%EF%BC%88%E5%88%A0%E9%99%A4%EF%BC%89%E9%87%8D%E5%A4%8D%E8%A1%8C.html
利用vim(gvim)的正则表达式实现代码自动匹配完成(等号两边数据交换)
http://www.vimer.cn/2010/01/%E5%88%A9%E7%94%A8vim%E7%9A%84%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%AE%9E%E7%8E%B0%E4%BB%A3%E7%A0%81%E8%87%AA%E5%8A%A8%E5%8C%B9%E9%85%8D%E5%AE%8C%E6%88%90%EF%BC%88%E7%AD%89%E5%8F%B7.html

如果vim是微软设计的(那个回形针)
http://www.vimer.cn/2009/10/%E5%A6%82%E6%9E%9Cvim%E6%98%AF%E5%BE%AE%E8%BD%AF%E8%AE%BE%E8%AE%A1%E7%9A%84.html



ctags和cscope

 

在Vim中使用ctags(几大跳转 C+] C+o [{ ]} {} :tags)
http://www.vimer.cn/2009/10/%E5%9C%A8vim%E4%B8%AD%E4%BD%BF%E7%94%A8ctags.html

在Vim(gvim)中使用cscope(复杂 不是很明白)
http://www.vimer.cn/2009/10/%E5%9C%A8vimgvim%E4%B8%AD%E4%BD%BF%E7%94%A8cscope.html

 

配色

Vim(gvim)配色方案推荐(加上csExplorer.vim 后:ColorSchemeExplorer)
http://www.vimer.cn/2009/10/vim%E9%85%8D%E8%89%B2%E6%8E%A8%E8%8D%90.html


js

vim的一个js代码整理的插件jsbeautify.vim(<leader>ff )
http://www.vimer.cn/2009/12/vim%E7%9A%84%E4%B8%80%E4%B8%AAjs%E4%BB%A3%E7%A0%81%E6%95%B4%E7%90%86%E7%9A%84%E6%8F%92%E4%BB%B6jsbeautify-vim.html

 

模板

vimer.cn原创vim(gvim)插件load_template正式发布(里面的那个template地址不知道怎么回事儿 我直接写死了 家里的台式机先不用这个了)
http://www.vimer.cn/2010/02/vimer-cn%E5%8E%9F%E5%88%9Bvimgvim%E6%8F%92%E4%BB%B6load_template%E6%AD%A3%E5%BC%8F%E5%8F%91%E5%B8%83.html



最后以防我的vimrc没了 先传一份

" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatiooble

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif


if(has("win32") || has("win95") || has("win64") || has("win16"))
let g:iswindows=1
let g:vimrc_iswindows=1

else
let g:iswindows=0
let g:vimrc_iswindows=0
endif
autocmd BufEnter * lcd %:p:h
if(g:iswindows==1)
"防止linux终端下无法拷贝
if has('mouse')
set mouse=a
endif
au GUIEnter * simalt ~x
endif




syntax on
set cindent
set ruler
set nocompatible
set nobackup
set nowritebackup
set noswapfile
set nu
set autoindent
set cursorline
set smartindent
set smarttab
set tabstop=4
set shiftwidth=4

set fileencodings=ucs-bom,utf-8,gbk,default,latin1

colorscheme elflord
set nocp
set tags=tags
set autochdir
filetype on
filetype plugin on
set completeopt=menu
let NERDShutUp=1



map <F3> :silent! Tlist<CR> "按下F3就可以呼出了
let Tlist_Ctags_Cmd='ctags' "因为我们放在环境变量里,所以可以直接执行
let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边
let Tlist_Show_One_File=0 "让taglist可以同时展示多个文件的函数列表,如果想只有1个,设置为1
let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏
let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim
let Tlist_Process_File_Always=0 "是否一直处理tags.1:处理;0:不处理。不是一直实时更新tags,因为没有必要
let Tlist_Inc_Winwidth=0

nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_ctags_bin = 'ctags'
let g:tagbar_width = 30




map <F5> :call Do_OneFileMake()<CR>
function Do_OneFileMake()
if expand("%:p:h")!=getcwd()
echohl WarningMsg | echo "Fail to make! This file is not in the current dir! Press <F7> to redirect to the dir of this file." | echohl None
return
endif
let sourcefileename=expand("%:t")
if (sourcefileename=="" || (&filetype!="cpp" && &filetype!="c"))
echohl WarningMsg | echo "Fail to make! Please select the right file!" | echohl None
return
endif
let deletedspacefilename=substitute(sourcefileename,' ','','g')
if strlen(deletedspacefilename)!=strlen(sourcefileename)
echohl WarningMsg | echo "Fail to make! Please delete the spaces in the filename!" | echohl None
return
endif
if &filetype=="c"
if g:iswindows==1
set makeprg=gcc\ -o\ %<.exe\ %
else
set makeprg=gcc\ -o\ %<\ %
endif
elseif &filetype=="cpp"
if g:iswindows==1
set makeprg=g++\ -o\ %<.exe\ %
else
set makeprg=g++\ -o\ %<\ %
endif
"elseif &filetype=="cs"
"set makeprg=csc\ \/nologo\ \/out:%<.exe\ %
endif
if(g:iswindows==1)
let outfilename=substitute(sourcefileename,'\(\.[^.]*\')' ,'.exe','g')
let toexename=outfilename
else
let outfilename=substitute(sourcefileename,'\(\.[^.]*\')' ,'','g')
let toexename=outfilename
endif
if filereadable(outfilename)
if(g:iswindows==1)
let outdeletedsuccess=delete(getcwd()."\\".outfilename)
else
let outdeletedsuccess=delete("./".outfilename)
endif
if(outdeletedsuccess!=0)
set makeprg=make
echohl WarningMsg | echo "Fail to make! I cannot delete the ".outfilename | echohl None
return
endif
endif
execute "silent make"
set makeprg=make
execute "normal :"
if filereadable(outfilename)
if(g:iswindows==1)
execute "!".toexename
else
execute "!./".toexename
endif
endif
execute "copen"
endfunction

"进行make的设置
map <F6> :call Do_make()<CR>
map <c-F6> :silent make clean<CR>
function Do_make()
set makeprg=make
execute "silent make"
execute "copen"
endfunction


let g:vimrc_author='yangyang'
let g:vimrc_email='duoduo3_69@163.com'
let g:vimrc_homepage=''

nmap <F11> :AuthorInfoDetect<cr>


map <F12> :call Do_CsTag()<CR>
nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR>
nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR>
nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR>
nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>:copen<CR>
function Do_CsTag()
let dir = getcwd()
if filereadable("tags")
if(g:iswindows==1)
let tagsdeleted=delete(dir."\\"."tags")
else
let tagsdeleted=delete("./"."tags")
endif
if(tagsdeleted!=0)
echohl WarningMsg | echo "Fail to do tags! I cannot delete the tags" | echohl None
return
endif
endif
if has("cscope")
silent! execute "cs kill -1"
endif
if filereadable("cscope.files")
if(g:iswindows==1)
let csfilesdeleted=delete(dir."\\"."cscope.files")
else
let csfilesdeleted=delete("./"."cscope.files")
endif
if(csfilesdeleted!=0)
echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.files" | echohl None
return
endif
endif
if filereadable("cscope.out")
if(g:iswindows==1)
let csoutdeleted=delete(dir."\\"."cscope.out")
else
let csoutdeleted=delete("./"."cscope.out")
endif
if(csoutdeleted!=0)
echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.out" | echohl None
return
endif
endif
if(executable('ctags'))
"silent! execute "!ctags -R --c-types=+p --fields=+S *"
silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ."
endif
if(executable('cscope') && has("cscope") )
if(g:iswindows!=1)
silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' > cscope.files"
else
silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files"
endif
silent! execute "!cscope -b"
execute "normal :"
if filereadable("cscope.out")
execute "cs add cscope.out"
endif
endif
endfunction

map fg : Dox<cr>
let g:DoxygenToolkit_authorName="duoduo"
let g:DoxygenToolkit_licenseTag="My own license\<enter>"
let g:DoxygenToolkit_undocTag="DOXIGEN_SKIP_BLOCK"
let g:DoxygenToolkit_briefTag_pre = "@brief\t"
let g:DoxygenToolkit_paramTag_pre = "@param\t"
let g:DoxygenToolkit_returnTag = "@return\t"
let g:DoxygenToolkit_briefTag_funcName = "no"
let g:DoxygenToolkit_maxFunctionProtoLines = 30

function InsertHeadDef(firstLine, lastLine)
if a:firstLine <1 || a:lastLine> line('$')
echoerr 'InsertHeadDef : Range overflow !(FirstLine:'.a:firstLine.';LastLine:'.a:lastLine.';ValidRange:1~'.line('$').')'
return ''
endif
let sourcefilename=expand("%:t")
let definename=substitute(sourcefilename,' ','','g')
let definename=substitute(definename,'\.','_','g')
let definename = toupper(definename)
exe 'normal '.a:firstLine.'GO'
call setline('.', '#ifndef _'.definename."_")
normal ==o
call setline('.', '#define _'.definename."_")
exe 'normal =='.(a:lastLine-a:firstLine+1).'jo'
call setline('.', '#endif')
let goLn = a:firstLine+2
exe 'normal =='.goLn.'G'
endfunction
function InsertHeadDefN()
let firstLine = 1
let lastLine = line('$')
let n=1
while n < 20
let line = getline(n)
if n==1
if line =~ '^\/\*.*$'
let n = n + 1
continue
else
break
endif
endif
if line =~ '^.*\*\/$'
let firstLine = n+1
break
endif
let n = n + 1
endwhile
call InsertHeadDef(firstLine, lastLine)
endfunction
nmap ,ha :call InsertHeadDefN()<CR>

function InsertIncludeFileI()
let sourcefilename=expand("%:t")
let outfilename=substitute(sourcefilename,'\(\.[^.]*\)$','.h','g')
call setline('.','#include "'.outfilename.'"')
endfunction
imap <c-b><c-h> <ESC>:call InsertIncludeFileI()<CR>
function InsertIncludeFileN()
let sourcefilename=expand("%:t")
let outfilename=substitute(sourcefilename,'\(\.[^.]*\)$','.h','g')
call setline('.','#include "'.outfilename.'"')
endfunction
nmap ,hh :call InsertIncludeFileN()<CR>



博客园一老哥整理,插件用法详细,继续更改。

http://www.cnblogs.com/wangkangluo1/archive/2011/06/09/2076755.html

 

 


posted on 2012-02-14 10:24  duoduo3_69  阅读(1272)  评论(3编辑  收藏  举报