vim 配置記錄

"顯示行號      
"set number "或者set  nu  
"map <F5> <Esc>:set nu<CR>   "映射F5顯示行號,參考"vim 按鍵映射"(http://www.pythonclub.org/vim/map-basic)  
"map <C-F5> <Esc>:set nonu<CR>   "映射Ctrl+F5爲不顯示行號  
nmap <F2> <c-w><c-w>
nmap <S-TAB> :tabnext<CR>
"nmap <TAB> :tabnext<CR>
nmap <C-n>  :tabe.<CR>


set syntax=c 
"檢測文件的類型      
syntax on
filetype on
filetype plugin on  
"記錄歷史的行數      
set history=1000  
  
"自動對齊      
"set autoindent  
"set cindent  
  
"智能選擇對齊方式      
"set smartindent  
  
"tab爲4個空格      
set tabstop=4  
  
"當前行之間交錯時使用4個空格      
"set shiftwidth=4  
  
"設置匹配模式,輸入做括號會出現右括號      
set showmatch  
  
"編輯時顯示光標狀態      
set ruler  
  
"高亮查找    
set hlsearch  
  
"粘貼插入  
set paste  
  
"快速匹配      
set incsearch  
  
"修改文件自動備份      
if has("vms")  
    set nobackup  
else  
    set nobackup  
endif  


"顯示行號
"set nu 


colorscheme  desert


"""""""""""""設置開啓ctags"""""""""""""     
map <F5> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>  
  
"第一個命令裏的分號是必不可少的。這個命令讓vim首先在當前目錄裏尋找tags文件,如果沒有找到  
"tags文件,或者沒有找到對應的目標,就到父目錄 中查找,一直向上遞歸。因爲tags文件中記錄的>路徑總是相對於tags文件所在的路徑,所以要使用第二個設置項來改變vim的當前目錄。   
set tags=tags;  
set autochdir  
"絕對路徑  
  
  
"""""""""""""""""Taglist設置"""""""""""""""""           
map <F2> : Tlist<CR>  ""按下F3就可以呼出了  
"let Tlist_Auto_Open = 1  "在啓動VIM後,自動打開taglist窗口  
let Tlist_Ctags_Cmd = '/usr/bin/ctags'  "設定ctags的位置  
let Tlist_Use_Right_Window=0 " 1爲讓窗口顯示在右邊,0爲顯示在左邊  
let Tlist_Show_One_File=0 "讓taglist可以同時展示多個文件的函數列表,設置爲1時不同時顯示>多個文件的tag,只顯示當前文件的  
let Tlist_File_Fold_Auto_Close=1 "同時顯示多個文件中的tag時,taglist只顯示當前文件tag,>其他文件的函數列表摺疊隱藏  
let Tlist_Exit_OnlyWindow=1 "當taglist是最後一個分割窗口時,自動退出vim  
"let Tlist_Use_SingleClick= 1    " 缺省情況下,在雙擊一個tag時,纔會跳到該tag定義的位置  
"let Tlist_Process_File_Always=0  "是否一直處理tags.1:處理;0:不處理  
  
  
  
"""""""""""""""""""""""cscope設置""""""""""""""""""      
set cscopequickfix=s-,c-,d-,i-,t-,e-    


if has("cscope")  
    set csprg=/usr/bin/cscope  
    set csto=0  
    set cst  
    set csverb  
    set cspc=3  
    "add any database in current dir  
    "if filereadable("cscope.out")  
    "cs add cscope.out  
    "else search cscope.out elsewhere  
    "else  
    let cscope_file=findfile("cscope.out", ".;")  
echo cscope_file
    let cscope_pre=matchstr(cscope_file, ".*/")  
    if !empty(cscope_file) && filereadable(cscope_file)  
        exe "cs add" cscope_file cscope_pre  
    endif        
    "endif  
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>$<CR>  
nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>  




"highlight Functions
syn match cFunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match cFunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
hi cFunctions guifg=#7fd02e cterm=bold ctermfg=yellow
syn match cClass "\<[a-zA-Z_][a-zA-Z_0-9]*\>::"me=e-2
hi cClass guifg=#7fd02e cterm=bold ctermfg=yellow


"nerdtree config
map <F1> :NERDTreeToggle<CR>
map <C-F1> :NERDTreeFind<CR>
let NERDTreeChDirMode=2 "選中root即設置爲當前目錄
let NERDTreeQuitOnOpen=1 "打開文件時關閉樹
let NERDTreeShowBookmarks=1 "顯示書籤
let NERDTreeMinimalUI=1 "不顯示幫助面板
let NERDTreeDirArrows=0 "目錄箭頭 1 顯示箭頭 0傳統+-|號
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章