入手imac,零零碎碎花了幾天時間,終於配置好了vim環境,記錄下。
在MAC下,我用了MacVim,開啟壓縮包,裡面有個mvim的指令碼,運行後可以在命令列中調用MacVim。
使用外掛程式:
pathogen,Taglist,NERD_tree,snipMate,nerocomplcache等~~~~
每個外掛程式的具體配置就不說了,網上一般都有,主要寫兩個我配置中出現的問題
1、蘋果預設ctags有點問題,需要自己重新下,自己編譯或者用port或者homebrew安裝都可以,我使用了homebrew。但是沒有制定PATH或者做軟連結的話,使用的還是MAC內建的ctags,我是用軟連結實現。
2、pathogen。按照晚上說明,建立autoload目錄,把pathogen.vim放在下面,在.vimrc中,添加
"pathogen
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
記得要在filetype plugin indent on前(沒搞清楚為啥)
然後建立bundle,在bundle下建立各個外掛程式的目錄,此時發現問題,部分外掛程式能用,但是部分外掛程式沒效果,折騰了半天發現,例如我的minibuf外掛程式是這麼配置的。
把minibuf.vim放在~/.vim/bundle/minibuf下,這時,minibuf是無效的,對比了其他幾個外掛程式,我在~/.vim/bundle/minibuf下在建立個plugin目錄,把minibuf.vim放在~/.vim/bundle/minibuf/plugin下,就可以了~~~
下面放上俺的vimrc
set nocompatiblesyntax oncolorscheme desertset guifont=Monaco:h16"pathogen call pathogen#runtime_append_all_bundles()call pathogen#helptags()if has("autocmd") filetype plugin indent on "根據檔案進行縮排 augroup vimrcEx au! autocmd FileType text setlocal textwidth=78 autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("{1}quot;) | \ exe "normal! g`\"" | \ endif augroup ENDelse "智慧縮排,相應的有cindent,官方說autoindent可以支援各種檔案的縮排,但是效果會比只支援C/C++的cindent效果會差一點,但筆者並沒有看出來 set autoindent " always set autoindenting on endif " has("autocmd")if(g:iswindows==1) "允許滑鼠的使用 "防止linux終端下無法拷貝 if has('mouse') set mouse=a endif au GUIEnter * simalt ~xendifset nuset incsearchset hlsearchmap <F9> :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>{1}lt;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")let tagsdeleted=delete("./"."tags") 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") let csfilesdeleted=delete("./"."cscope.files") 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") let csoutdeleted=delete("./"."cscope.out") 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") ) silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files" silent! execute "!cscope -b" execute "normal :" if filereadable("cscope.out") execute "cs add cscope.out" endif endifendfunction"taglistlet Tlist_Show_One_File=1let Tlist_Ctags_Cmd='ctags' "因為我們放在環境變數裡,所以可以直接執行let Tlist_Exit_OnlyWindow=1let Tlist_Use_Right_Windos=0let Tlist_File_Fold_Auto_Close=1 "非當前檔案,函數列表摺疊隱藏let Tlist_Exit_OnlyWindow=1 "當taglist是最後一個分割視窗時,自動推出vimmap <F3> :silent! Tlist<CR>"NERD_commenterlet NERDShutUp=1"Doxygenmap fg : Dox<cr>let g:DoxygenToolkit_authorName="dantezhu"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"minibuflet g:miniBufExplMapWindowNavVim = 1 "<C-jklh>切換let g:miniBufExplMapCTabSwitchBufs = 1 "<C-Tab>切換視窗let g:miniBufExplModSelTarget = 1"neocomlcachlet 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 = 4"turn off auto completelet g:neocomplcache_disable_auto_complete = 1"use supertablet g:SuperTabDefaultCompletionType="context""NERD_treenmap <F4> :NERDTree <CR>let NERDTreeWinPos = "right" "where NERD tree window is placed on the screen