vim設定檔~/.vimrc

來源:互聯網
上載者:User

標籤:

在啟動vim時,目前使用者根目錄下的.vimrc檔案會被自動讀取,該檔案可以包含一些設定甚至指令碼。

"設定編碼set encoding=utf-8set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936set fileencodings=utf-8,ucs-bom,chinese "語言設定set langmenu=zh_CN.UTF-8 "設定文法高亮syntax enablesyntax on "設定色彩配置colorscheme torte "可以在buffer的任何地方使用滑鼠set mouse=aset selection=exclusiveset selectmode=mouse,key "高亮顯示匹配的括弧set showmatch "去掉vi一致性set nocompatible "設定縮排set tabstop=4set softtabstop=4set shiftwidth=4set autoindentset cindentif &term=="xterm"    set t_Co=8    set t_Sb=^[[4%dm    set t_Sf=^[[3%dmendif "開啟檔案類型自動檢測功能filetype on "設定taglistlet Tlist_Show_One_File=0   "顯示多個檔案的tagslet Tlist_File_Fold_Auto_Close=1 "非當前檔案,函數列表摺疊隱藏let Tlist_Exit_OnlyWindow=1 "在taglist是最後一個視窗時退出vimlet Tlist_Use_SingleClick=1 "單擊時跳轉let Tlist_GainFocus_On_ToggleOpen=1 "開啟taglist時獲得輸入焦點let Tlist_Process_File_Always=1 "不管taglist視窗是否開啟,始終解析檔案中的tag "設定WinManager外掛程式let g:winManagerWindowLayout=‘FileExplorer|TagList‘nmap wm :WMToggle<cr>map <silent> <F9> :WMToggle<cr> "將F9綁定至WinManager,即開啟WimManager "設定CSCOPEset cscopequickfix=s-,c-,d-,i-,t-,e- "設定是否使用quickfix視窗顯示cscope結果 "設定Grep外掛程式nnoremap <silent> <F3> :Grep<CR> "設定一鍵編譯map <F6> :make<CR> "設定自動補全filetype plugin indent on   "開啟檔案類型檢測set completeopt=longest,menu "關掉智能補全時的預覽視窗 "啟動vim時如果存在tags則自動載入if exists("tags")    set tags=./tagsendif "設定按F12就更新tags的方法map <F12> :call Do_CsTag()<CR>nmap <[email protected]>s :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR>nmap <[email protected]>g :cs find g <C-R>=expand("<cword>")<CR><CR>nmap <[email protected]>c :cs find c <C-R>=expand("<cword>")<CR><CR>:copen<CR>nmap <[email protected]>t :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR>nmap <[email protected]>e :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR>nmap <[email protected]>f :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR>nmap <[email protected]>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR>nmap <[email protected]>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        endifendfunction "設定預設shellset shell=bash "設定VIM記錄的曆史數set history=400 "設定當檔案被外部改變的時侯自動讀入檔案if exists("&autoread")    set autoreadendif "設定ambiwidthset ambiwidth=double "設定檔案類型set ffs=unix,dos,mac "設定增量搜尋模式set incsearch "設定靜音set noerrorbellsset novisualbellset t_vb= "不要備份檔案set nobackupset nowb

根據自己需要進行設定,一般我比較偏愛的設定為:

set encoding=utf-8set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936set fileencodings=utf-8,ucs-bom,chinese set langmenu=zh_CN.UTF-8 syntax enablesyntax on set mouse=aset selection=exclusiveset selectmode=mouse,key set showmatch set nocompatible set tabstop=4set softtabstop=4set shiftwidth=4set autoindentset cindent filetype onset shell=bash set history=400 filetype plugin indent on set completeopt=longest,menu

 

vim設定檔~/.vimrc

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.