日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

linux .vimrc教程,vim配置文件~/.vimrc

發(fā)布時(shí)間:2024/9/19 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux .vimrc教程,vim配置文件~/.vimrc 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在啟動(dòng)vim時(shí),當(dāng)前用戶(hù)根目錄下的.vimrc文件會(huì)被自動(dòng)讀取,該文件可以包含一些設(shè)置甚至腳本。

"設(shè)置編碼

set encoding=utf-8

set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

set fileencodings=utf-8,ucs-bom,chinese

"語(yǔ)言設(shè)置

set langmenu=zh_CN.UTF-8

"設(shè)置語(yǔ)法高亮

syntax enable

syntax on

"設(shè)置配色方案

colorscheme torte

"可以在buffer的任何地方使用鼠標(biāo)

set mouse=a

set selection=exclusive

set selectmode=mouse,key

"高亮顯示匹配的括號(hào)

set showmatch

"去掉vi一致性

set nocompatible

"設(shè)置縮進(jìn)

set tabstop=4

set softtabstop=4

set shiftwidth=4

set autoindent

set cindent

if &term=="xterm"

set t_Co=8

set t_Sb=^[[4%dm

set t_Sf=^[[3%dm

endif

"打開(kāi)文件類(lèi)型自動(dòng)檢測(cè)功能

filetype on

"設(shè)置taglist

let Tlist_Show_One_File=0? "顯示多個(gè)文件的tags

let Tlist_File_Fold_Auto_Close=1 "非當(dāng)前文件,函數(shù)列表折疊隱藏

let Tlist_Exit_OnlyWindow=1 "在taglist是最后一個(gè)窗口時(shí)退出vim

let Tlist_Use_SingleClick=1 "單擊時(shí)跳轉(zhuǎn)

let Tlist_GainFocus_On_ToggleOpen=1 "打開(kāi)taglist時(shí)獲得輸入焦點(diǎn)

let Tlist_Process_File_Always=1 "不管taglist窗口是否打開(kāi),始終解析文件中的tag

"設(shè)置WinManager插件

let g:winManagerWindowLayout='FileExplorer|TagList'

nmap wm :WMToggle

map :WMToggle "將F9綁定至WinManager,即打開(kāi)WimManager

"設(shè)置CSCOPE

set cscopequickfix=s-,c-,d-,i-,t-,e- "設(shè)定是否使用quickfix窗口顯示cscope結(jié)果

"設(shè)置Grep插件

nnoremap :Grep

"設(shè)置一鍵編譯

map :make

"設(shè)置自動(dòng)補(bǔ)全

filetype plugin indent on? "打開(kāi)文件類(lèi)型檢測(cè)

set completeopt=longest,menu "關(guān)掉智能補(bǔ)全時(shí)的預(yù)覽窗口

"啟動(dòng)vim時(shí)如果存在tags則自動(dòng)加載

if exists("tags")

set tags=./tags

endif

"設(shè)置按F12就更新tags的方法

map :call Do_CsTag()

nmap s :cs find s =expand(""):copen

nmap g :cs find g =expand("")

nmap c :cs find c =expand(""):copen

nmap t :cs find t =expand(""):copen

nmap e :cs find e =expand(""):copen

nmap f :cs find f =expand(""):copen

nmap i :cs find i ^=expand("")$:copen

nmap d :cs find d =expand(""):copen

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

"設(shè)置默認(rèn)shell

set shell=bash

"設(shè)置VIM記錄的歷史數(shù)

set history=400

"設(shè)置當(dāng)文件被外部改變的時(shí)侯自動(dòng)讀入文件

if exists("&autoread")

set autoread

endif

"設(shè)置ambiwidth

set ambiwidth=double

"設(shè)置文件類(lèi)型

set ffs=unix,dos,mac

"設(shè)置增量搜索模式

set incsearch

"設(shè)置靜音模式

set noerrorbells

set novisualbell

set t_vb=

"不要備份文件

set nobackup

set nowb

--------------------------------------分割線 --------------------------------------

--------------------------------------分割線 --------------------------------------

與50位技術(shù)專(zhuān)家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的linux .vimrc教程,vim配置文件~/.vimrc的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。