发布时间:2022-06-29 文章分类:编程知识 投稿人:赵颖 字号: 默认 | | 超大 打印

贴个自个用的vimrc

分类: Vim 151人阅读 评论(0) 收藏 举报
[plain] view plaincopyprint?

  1. "~/.vimrc(configurationfileforvimonly)
  2. setfileencodings=utf-8,gb2312,gbk,gb18030
  3. settermencoding=utf-8
  4. "vundlebegin插件管理
  5. filetypeoff"required!
  6. setrtp+=~/.vim/bundle/vundle/
  7. callvundle#rc()
  8. "letVundlemanageVundle
  9. "required!
  10. Bundle'gmarik/vundle'
  11. "vim-scriptsrepos
  12. Bundle'STL-improved'
  13. Bundle'taglist.vim'
  14. Bundle'tag_in_new_tab'
  15. Bundle'autoload_cscope.vim'
  16. Bundle'CmdlineComplete'
  17. Bundle'xptemplate'
  18. Bundle'neocomplcache'
  19. Bundle'genutils'
  20. Bundle'lookupfile'
  21. Bundle'autopreview'
  22. Bundle'echofunc.vim'
  23. Bundle'grep.vim'
  24. Bundle'a.vim'
  25. Bundle'The-NERD-Commenter'
  26. Bundle'The-NERD-tree'
  27. Bundle'Source-Explorer-srcexpl.vim'
  28. Bundle'trinity.vim'
  29. "underlinuxneedexec'dos2unix~/.vim/bundle/QFixToggle/plugin/qfixtoggle.vim'
  30. Bundle'QFixToggle'
  31. Bundle'Color-Sampler-Pack'
  32. Bundle'txt.vim'
  33. Bundle'mru.vim'
  34. Bundle'Align'
  35. Bundle'DoxygenToolkit.vim'
  36. Bundle'headerGatesAdd.vim'
  37. Bundle'ShowMarks'
  38. "nongithubrepos
  39. "autocomplete.match.pair.vim,这个安装完必须在.vim/bundle/449512/目录下创建plugin目录并在其下创建软链接指向autocomplete.match.pair.vim,否则不工作,另外不知为何(号不会自动完成配对
  40. Bundle'git://gist.github.com/449512.git'
  41. "...
  42. filetypepluginindenton"required!
  43. "vundleend
  44. colorschemedesert
  45. synon"显高亮
  46. "setruler"屏幕右下角显示当前光标所处位置
  47. setlaststatus=2"alwayshavestatus-line'
  48. setstatusline=%F%m%r%h%w\%{&ff}\%Y\[ascii:%b\hex:0x\%02.2B]\[%{(&fenc\==\\"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}]\%=%l/%L,%v\%p%%
  49. setnumber
  50. setautochdir"自动切换当前目录为当前文件所在的目录
  51. setautoread"文件被其他程序修改时自动载入
  52. "Linesfolding
  53. "setfoldenable
  54. "setfoldnestmax=1
  55. "setfoldmethod=syntax
  56. "setfoldlevel=1
  57. "allowbackspacingovereverythingininsertmode
  58. setbackspace=indent,eol,start
  59. setshiftwidth=4
  60. settabstop=4
  61. setsofttabstop=4
  62. setexpandtab
  63. setlist"显示Tab符,使用一高亮竖线代替
  64. setlistchars=tab:\|\,
  65. "http://vimcdoc.sourceforge.net/doc/indent.html
  66. "g0类的public顶格写
  67. ":0将case标号放在switch()缩进位置之后的N个字符处
  68. "N-snamespace下顶格
  69. "(0条件语句多个条件在不同行时下一行与上一行对齐
  70. setcinoptions=g0,:0,N-s,(0
  71. setautoindent
  72. setsmartindent
  73. "setmouse=a
  74. setmps+=<:>"让<>可以使用%跳转
  75. sethid"allowtochangebufferwithoutsaving
  76. setshortmess=atI"shortensmessagestoavoid'pressakey'prompt
  77. setlazyredraw"donotredrawwhileexecutingmacros(muchfaster)
  78. "SetNumberformattonull(defaultisoctal),whenpressCTRL-Aonnumber
  79. "like007,itwouldnotbecome010
  80. setnf=
  81. "InVisualBlockMode,cursorcanbepositionedwherethereisnoactualcharacter
  82. setve=block
  83. setignorecase"Setsearch/replacepatterntoignorecase
  84. setsmartcase"Setsmartcasemodeon,Ifthereisuppercasecharacterinthesearchpatern,the'ignorecase'optionwillbeoverride.
  85. setshowcmd"displayincompletecommands
  86. setincsearch"doincrementalsearching
  87. sethlsearch"highlightsearch
  88. setmagic"Enablemagicmatching
  89. setshowmatch"showmatchingparen
  90. setwildmenu"增强模式中的命令行自动完成操作
  91. "Autochangetherootdirectory
  92. letNERDTreeChDirMode=2
  93. letg:DoxygenToolkit_blockHeader="--------------------------------------------------------------------------"
  94. letg:DoxygenToolkit_blockFooter="--------------------------------------------------------------------------"
  95. letg:DoxygenToolkit_authorName="帅得不敢出门c++群31843264"
  96. letg:DoxygenToolkit_versionString="0.1.00"
  97. letg:DoxygenToolkit_briefTag_funcName="yes"
  98. autocmdBufNewFile*.{h,hpp,c,cpp}DoxAuthor
  99. "<Space>keyatnormalmodel.
  100. "nnoremap<Space>i<Esc>l
  101. "Switchingbetweenbuffers.
  102. nnoremap<C-h><C-W>h
  103. nnoremap<C-j><C-W>j
  104. nnoremap<C-k><C-W>k
  105. nnoremap<C-l><C-W>l
  106. inoremap<C-h><Esc><C-W>h
  107. inoremap<C-j><Esc><C-W>j
  108. inoremap<C-k><Esc><C-W>k
  109. inoremap<C-l><Esc><C-W>l
  110. "SetUpandDownnon-linewise
  111. noremap<Up>gk
  112. noremap<Down>gj
  113. "useMetakey(Windows:Alt)tomovecursorininsertmode.
  114. "Note:ifsysteminstall"LingoesTranslator",
  115. "youwillneedchange/disabledhotkey.
  116. noremap!<M-j><Down>
  117. noremap!<M-k><Up>
  118. noremap!<M-h><left>
  119. noremap!<M-l><Right>
  120. setpastetoggle=<F2>
  121. "nnoremap<F2>:setinvnumbernumber?<CR>:setinvpastepaste?<CR>
  122. "imap<F2><C-O>:setinvpastepaste?<CR><C-O>:setinvnumbernumber?<CR>
  123. nnoremap<silent><F3>:Rgrep<CR>
  124. nnoremap<F6>:AutoPreviewToggle<CR>
  125. inoremap<F6><ESC>:AutoPreviewToggle<CR>i
  126. "Openandcloseallthethreepluginsonthesametime
  127. nmap<F8>:TrinityToggleAll<CR>
  128. "Openandclosethesrcexpl.vimseparately
  129. nmap<F7>:TrinityToggleSourceExplorer<CR>
  130. "Openandclosethetaglist.vimseparately
  131. nmap<F10>:TrinityToggleTagList<CR>
  132. "OpenandclosetheNERD_tree.vimseparately
  133. nmap<F11>:TrinityToggleNERDTree<CR>
  134. "--lookupfile--
  135. letg:LookupFile_MinPatLength=2"最少输入2个字符才开始查找
  136. letg:LookupFile_PreserveLastPattern=0"不保存上次查找的字符串
  137. "letg:LookupFile_PreservePatternHistory=1"保存查找历史
  138. letg:LookupFile_AlwaysAcceptFirst=1"回车打开第一个匹配项目
  139. letg:LookupFile_AllowNewFiles=0"不允许创建不存在的文件
  140. iffilereadable("./filenametags")"设置tag文件的名字
  141. letg:LookupFile_TagExpr='"./filenametags"'
  142. endif
  143. "--taglist--
  144. settags=tags;
  145. letTlist_Auto_Update=1
  146. "--cscope--
  147. letg:autocscope_menus=0
  148. "Usequickfixwindowtoshowcscoperesults
  149. setcscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-
  150. "'csto'被设为0,cscope数据库先被搜索,搜索失败的情况下在搜索标签文件
  151. "设定了'cscopetag',这样所有的:tag命令就会实际上调用:cstag。这包括:tag、Ctrl-]及vim-t。
  152. "结果是一般的tag命令不仅搜索由ctags产生的标签文件,同时也搜索cscope数据库,但是好像有bug,二者共存时有的无法搜索
  153. ifhas("cscope")
  154. setcsprg=/usr/bin/cscope
  155. "Usebothcscopeandctag
  156. setcscopetag
  157. "Showmsgwhencscopedbadded
  158. setcscopeverbose
  159. "Usecscopefordefinitionsearchfirst
  160. setcscopetagorder=0
  161. endif
  162. nmap<C-_>s:csfinds<C-R>=expand("<cword>")<CR><CR>
  163. nmap<C-_>g:csfindg<C-R>=expand("<cword>")<CR><CR>
  164. nmap<C-_>c:csfindc<C-R>=expand("<cword>")<CR><CR>
  165. nmap<C-_>t:csfindt<C-R>=expand("<cword>")<CR><CR>
  166. nmap<C-_>e:csfinde<C-R>=expand("<cword>")<CR><CR>
  167. nmap<C-_>f:csfindf<C-R>=expand("<cfile>")<CR><CR>
  168. nmap<C-_>i:csfindi^<C-R>=expand("<cfile>")<CR>{1}lt;CR>
  169. nmap<C-_>d:csfindd<C-R>=expand("<cword>")<CR><CR>
  170. "解决cscope与tag共存时ctrl+]有时不正常的bug
  171. nmap<C-]>:tj<C-R>=expand("<cword>")<CR><CR>
  172. "VimTip329:Amapforswappingwords
  173. "http://vim.sourceforge.net/tip_view.php?tip_id=
  174. "Thenwhenyouputthecursoronorinaword,press"\sw",and
  175. "thewordwillbeswappedwiththenextword.Thewordsmay
  176. "evenbeseparatedbypunctuation(suchas"abc=def").
  177. nnoremap<unique><silent><leader>sw"_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o>
  178. "DisableAutoComplPop.
  179. letg:acp_enableAtStartup=0
  180. "Useneocomplcache.
  181. letg:neocomplcache_enable_at_startup=1
  182. "Usesmartcase.
  183. letg:neocomplcache_enable_smart_case=1
  184. "Usecamelcasecompletion.
  185. letg:neocomplcache_enable_camel_case_completion=1
  186. "Useunderbarcompletion.
  187. letg:neocomplcache_enable_underbar_completion=1
  188. "Setminimumsyntaxkeywordlength.
  189. letg:neocomplcache_min_syntax_length=3
  190. letg:neocomplcache_lock_buffer_name_pattern='\*ku\*'
  191. letg:neocomplcache_enable_ignore_case=0
  192. "Definedictionary.
  193. letg:neocomplcache_dictionary_filetype_lists={
  194. \'default':'',
  195. \'vimshell':$HOME.'/.vimshell_hist',
  196. \'scheme':$HOME.'/.gosh_completions'
  197. \}
  198. "Definekeyword.
  199. if!exists('g:neocomplcache_keyword_patterns')
  200. letg:neocomplcache_keyword_patterns={}
  201. endif
  202. letg:neocomplcache_keyword_patterns['default']='\h\w*'
  203. "Recommendedkey-mappings.
  204. "<CR>:closepopupandsaveindent.
  205. inoremap<expr><CR>neocomplcache#smart_close_popup()."\<CR>"
  206. "<TAB>:completion.
  207. "inoremap<expr><TAB>pumvisible()?"\<C-n>":"\<TAB>"
  208. "<C-h>,<BS>:closepopupanddeletebackwordchar.
  209. inoremap<expr><C-h>neocomplcache#smart_close_popup()."\<C-h>"
  210. inoremap<expr><BS>neocomplcache#smart_close_popup()."\<C-h>"
  211. inoremap<expr><C-y>neocomplcache#close_popup()
  212. inoremap<expr><C-e>neocomplcache#cancel_popup()
  213. "Fastremovehighlightsearch
  214. nmap<silent><leader><cr>:noh<cr>
  215. "每行超过80个的字符用下划线标示
  216. auBufRead,BufNewFile*.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.hs,*.vim2matchUnderlined/.\%81v/
  217. "超过80个的字符高亮
  218. "auBufWinEnter*letw:m1=matchadd('Search','\%<88v.\%>81v',-1)
  219. "auBufWinEnter*letw:m2=matchadd('ErrorMsg','\%>80v.\+',-1)
  220. "高亮显示txt需要txt.vim
  221. auBufRead,BufNewFile*setfiletypetxt
  222. "Restorethelastquitpositionwhenopenfile.
  223. autocmdBufReadPost*
  224. \ifline("'\"")>0&&line("'\"")<=line("{1}quot;)|
  225. \exe"normalg'\""|
  226. \endif
  227. "自动更新最后修改时间
  228. function!AutoUpdateTheLastUpdateInfo()
  229. lets:original_pos=getpos(".")
  230. lets:regexp="^\\s*\\([#\\\"\\*]\\|\\/\\/\\)\\s\\?[lL]ast\\([uU]pdate\\|[cC]hange\\):"
  231. lets:lu=search(s:regexp)
  232. ifs:lu!=0
  233. lets:update_str=matchstr(getline(s:lu),s:regexp)
  234. callsetline(s:lu,s:update_str.strftime("%Y-%m-%d%H:%M:%S",localtime()))
  235. callsetpos(".",s:original_pos)
  236. endif
  237. endfunction
  238. autocmdBufWritePost*.{h,hpp,c,cpp}callAutoUpdateTheLastUpdateInfo()
  239. autocmdBufNewFile*.{h,hpp,c,cpp}exec'callappend(0,"\/\/LastUpdate:".strftime("%Y-%m-%d%H:%M:%S",localtime()))'
" ~/.vimrc (configuration file for vim only)
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
"vundle begin 插件管理
filetype off                   " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" vim-scripts repos
Bundle 'STL-improved'
Bundle 'taglist.vim'
Bundle 'tag_in_new_tab'
Bundle 'autoload_cscope.vim'
Bundle 'CmdlineComplete'
Bundle 'xptemplate'
Bundle 'neocomplcache'
Bundle 'genutils'
Bundle 'lookupfile'
Bundle 'autopreview'
Bundle 'echofunc.vim'
Bundle 'grep.vim'
Bundle 'a.vim'
Bundle 'The-NERD-Commenter'
Bundle 'The-NERD-tree'
Bundle 'Source-Explorer-srcexpl.vim'
Bundle 'trinity.vim'
"under linux need exec 'dos2unix ~/.vim/bundle/QFixToggle/plugin/qfixtoggle.vim'
Bundle 'QFixToggle'
Bundle 'Color-Sampler-Pack'
Bundle 'txt.vim'
Bundle 'mru.vim'
Bundle 'Align'
Bundle 'DoxygenToolkit.vim'
Bundle 'headerGatesAdd.vim'
Bundle 'ShowMarks'
" non github repos
" autocomplete.match.pair.vim,这个安装完必须在.vim/bundle/449512/目录下创建plugin目录并在其下创建软链接指向autocomplete.match.pair.vim,否则不工作,另外不知为何(号不会自动完成配对
Bundle 'git://gist.github.com/449512.git'
" ...
filetype plugin indent on     " required!
"vundle end
colorscheme desert
syn on "显高亮
"set ruler  "屏幕右下角显示当前光标所处位置
set laststatus=2 " always have status-line'
set statusline=%F%m%r%h%w\ %{&ff}\ %Y\ [ascii:%b\ hex:0x\%02.2B]\ [%{(&fenc\ ==\ \"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}]\ %=%l/%L,%v\ %p%%
set number
set autochdir          " 自动切换当前目录为当前文件所在的目录
set autoread           " 文件被其他程序修改时自动载入
" Lines folding
"set foldenable
"set foldnestmax=1
"set foldmethod=syntax
"set foldlevel=1
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
set list                     " 显示Tab符,使用一高亮竖线代替
set listchars=tab:\|\ ,
" http://vimcdoc.sourceforge.net/doc/indent.html
" g0 类的public顶格写
" :0 将 case 标号放在 switch() 缩进位置之后的 N 个字符处
" N-s namespace 下顶格
" (0  条件语句多个条件在不同行时下一行与上一行对齐
set cinoptions=g0,:0,N-s,(0
set autoindent
set smartindent
"set mouse=a
set mps+=<:>            "让<>可以使用%跳转
set hid " allow to change buffer without saving
set shortmess=atI " shortens messages to avoid 'press a key' prompt
set lazyredraw "do not redraw while executing macros (much faster)
" Set Number format to null(default is octal) , when press CTRL-A on number
" like 007, it would not become 010
set nf=
" In Visual Block Mode, cursor can be positioned where there is no actual character
set ve=block
set ignorecase " Set search/replace pattern to ignore case
set smartcase " Set smartcase mode on, If there is upper case character in the search patern, the 'ignorecase' option will be override.
set showcmd     " display incomplete commands
set incsearch       " do incremental searching
set hlsearch  "highlight search
set magic   " Enable magic matching
set showmatch " show matching paren
set wildmenu "增强模式中的命令行自动完成操作
" Auto change the root directory
let NERDTreeChDirMode=2
let g:DoxygenToolkit_blockHeader="--------------------------------------------------------------------------"
let g:DoxygenToolkit_blockFooter="--------------------------------------------------------------------------"
let g:DoxygenToolkit_authorName="帅得不敢出门 c++群31843264"
let g:DoxygenToolkit_versionString="0.1.00"
let g:DoxygenToolkit_briefTag_funcName="yes"
autocmd BufNewFile *.{h,hpp,c,cpp} DoxAuthor
" <Space> key at normal model.
"nnoremap <Space> i <Esc>l
" Switching between buffers.
nnoremap <C-h> <C-W>h
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-l> <C-W>l
inoremap <C-h> <Esc><C-W>h
inoremap <C-j> <Esc><C-W>j
inoremap <C-k> <Esc><C-W>k
inoremap <C-l> <Esc><C-W>l
" Set Up and Down non-linewise
noremap <Up> gk
noremap <Down> gj
" use Meta key(Windows:Alt) to move cursor in insert mode.
" Note: if system install "Lingoes Translator",
"   you will need change/disabled hot key.
noremap! <M-j> <Down>
noremap! <M-k> <Up>
noremap! <M-h> <left>
noremap! <M-l> <Right>
set pastetoggle=<F2>
"nnoremap <F2> :set invnumber number?<CR>:set invpaste paste?<CR>
"imap <F2> <C-O>:set invpaste paste?<CR><C-O>:set invnumber number?<CR>
nnoremap <silent> <F3> :Rgrep<CR>
nnoremap <F6> :AutoPreviewToggle<CR>
inoremap <F6> <ESC>:AutoPreviewToggle<CR>i
" Open and close all the three plugins on the same time
nmap <F8>   :TrinityToggleAll<CR>
" Open and close the srcexpl.vim separately
nmap <F7>   :TrinityToggleSourceExplorer<CR>
" Open and close the taglist.vim separately
nmap <F10>  :TrinityToggleTagList<CR>
" Open and close the NERD_tree.vim separately
nmap <F11>  :TrinityToggleNERDTree<CR>
" --lookupfile--
let g:LookupFile_MinPatLength = 2               "最少输入2个字符才开始查找
let g:LookupFile_PreserveLastPattern = 0        "不保存上次查找的字符串
"let g:LookupFile_PreservePatternHistory = 1     "保存查找历史
let g:LookupFile_AlwaysAcceptFirst = 1          "回车打开第一个匹配项目
let g:LookupFile_AllowNewFiles = 0              "不允许创建不存在的文件
if filereadable("./filenametags")                "设置tag文件的名字
let g:LookupFile_TagExpr ='"./filenametags"'
endif
" -- taglist --
set tags=tags;
let Tlist_Auto_Update=1
" -- cscope --
let g:autocscope_menus=0
" Use quickfix window to show cscope results
set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-
"'csto' 被设为 0,cscope 数据库先 被搜索,搜索失败的情况下在搜索标签文件
"设定了 'cscopetag',这样所有的 :tag 命令就会实际上调用 :cstag。这包括 :tag、Ctrl-] 及 vim -t。
"结果是一般的 tag 命令不仅搜索由 ctags 产生的标签文 件,同时也搜索 cscope 数据库,但是好像有bug,二者共存时有的无法搜索
if has("cscope")
set csprg=/usr/bin/cscope
" Use both cscope and ctag
set cscopetag
" Show msg when cscope db added
set cscopeverbose
" Use cscope for definition search first
set cscopetagorder=0
endif
nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><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>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>{1}lt;CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
" 解决cscope与tag共存时ctrl+]有时不正常的bug
nmap <C-]> :tj <C-R>=expand("<cword>")<CR><CR>
" VimTip 329: A map for swapping words
" http://vim.sourceforge.net/tip_view.php?tip_id=
" Then when you put the cursor on or in a word, press "\sw", and
" the word will be swapped with the next word.  The words may
" even be separated by punctuation (such as "abc = def").
nnoremap <unique> <silent><leader>sw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o>
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
let g:neocomplcache_enable_ignore_case = 0
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <expr><CR>  neocomplcache#smart_close_popup() . "\<CR>"
" <TAB>: completion.
"inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y>  neocomplcache#close_popup()
inoremap <expr><C-e>  neocomplcache#cancel_popup()
"Fast remove highlight search
nmap <silent> <leader><cr> :noh<cr>
" 每行超过80个的字符用下划线标示
au BufRead,BufNewFile *.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.hs,*.vim 2match Underlined /.\%81v/
" 超过80个的字符高亮
"au BufWinEnter * let w:m1=matchadd('Search', '\%<88v.\%>81v', -1)
"au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
"高亮显示txt 需要txt.vim
au BufRead,BufNewFile * setfiletype txt
" Restore the last quit position when open file.
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("{1}quot;) |
\     exe "normal g'\"" |
\ endif
" 自动更新最后修改时间
function! AutoUpdateTheLastUpdateInfo()
let s:original_pos = getpos(".")
let s:regexp = "^\\s*\\([#\\\"\\*]\\|\\/\\/\\)\\s\\?[lL]ast \\([uU]pdate\\|[cC]hange\\):"
let s:lu = search(s:regexp)
if s:lu != 0
let s:update_str = matchstr(getline(s:lu), s:regexp)
call setline(s:lu, s:update_str . strftime("%Y-%m-%d %H:%M:%S", localtime()))
call setpos(".", s:original_pos)
endif
endfunction
autocmd BufWritePost *.{h,hpp,c,cpp} call AutoUpdateTheLastUpdateInfo()
autocmd BufNewFile *.{h,hpp,c,cpp} exec 'call append(0, "\/\/ Last Update:" . strftime("%Y-%m-%d %H:%M:%S", localtime()))'

已经放到github上了地址是,以后将不再更新此贴,最新的可到git上查看

https://github.com/tczengming/myvim/

希望能给大家做一个参考。插件用bundle (也有人叫vundle)管理的,推荐大家使用bundle,插件安装升级很方便

只要一个vimrc

先安装bundle

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

然后可下载我的.vimrc替换你的.vimrc

git clonehttps://github.com/tczengming/myvim.git

下载后用myvim/myvimrc替换你的.vimrc (可自行修改其内容)

然后在vim中执行

BundleInstall! 就可以自动地更新安装插件,不用再手动去网上一个个下最新包了。
缷载插件 :BundleClean

Janus: Vim Distribution

This is a distribution of plug-ins and mappings for Vim, Gvim and MacVim.

It is designed to provide minimal working environment using the most popular plug-ins and the most common mappings.

The distribution is completely customisable using a ~/.vimrc.before and ~/.vimrc.after Vim RC files.