ONE_VimRC_FROM_MY_LINUX
set foldmethod=syntax
"啓動時不要自動摺疊代碼
set foldlevel=100
"依標記摺疊
set foldmethod=marker
"顯示行號
set number
"打開光標的行列位置顯示功能
"set ruler
"顯示中文引號
set ambiwidth=double
"行高亮
"set cursorline
"列高亮,與函數列表有衝突
"set cursorcolumn
"設置命令行的高度
set cmdheight=2
"高亮搜索的關鍵字
set hlsearch
"搜索忽略大小寫
set ignorecase
"設置命令歷史行數
set history=100
"不要閃爍
"set novisualbell
"顯示TAB健
set list
set listchars=tab:>-,trail:-
"高亮字符,讓其不受100列限制
":highlight OverLength ctermbg=red ctermfg=white guibg=grey guifg=white
":match OverLength '\%101v.*'
:filetype plugin on
:helptags $HOME/.vim/doc/
""""""""""""""""""""""""""""""
" cscope
""""""""""""""""""""""""""""""
if has("cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
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>
" Using 'CTRL-spacebar' then a search type makes the vim window
" split horizontally, with search result displayed in
" the new window.
nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR>
" Hitting CTRL-space *twice* before the search type does a vertical
" split instead of a horizontal one
nmap <C-Space><C-Space>s
\:vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>g
\:vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>c
\:vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>t
\:vert scs find t <C-R>=expand("<rrrrcword>")<CR><CR>
nmap <C-Space><C-Space>e
\:vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>i
\:vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-Space><C-Space>d
\:vert scs find d <C-R>=expand("<cword>")<CR><CR>
""""""""""""""""""""""""""""""
" lookupfile setting
""""""""""""""""""""""""""""""
" 指定英文逗號作爲<leader>鍵
let mapleader=","
let g:LookupFile_TagExpr = '"filenametags"'
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
nmap <silent> <leader>lk <Plug>LookupFile<cr> "映射LookupFile爲,lk
nmap <silent> <leader>ll :LUBufs<cr> "映射LUBufs爲,ll
nmap <silent> <leader>lw :LUWalk<cr> "映射LUWalk爲,lw
" 在指定目錄生成filenametags,並使lookupfile將這個文件作爲查找源
function SetRootOfTheProject(path)
" 進入指定目錄
exe 'cd '.a:path
" 生成文件標籤
exe '!genfiletags'
" 獲取標籤文件的路徑
let tagFilePath = genutils#CleanupFileName(a:path.'/filenametags')
" 設置LookupFile插件的全局變量,使之以上面生成的標籤文件作爲查找源
exe "let g:LookupFile_TagExpr='\"".tagFilePath."\"'"
endfunction
" 設置當前位置爲工程的根目錄
function SetHereTheRoot()
call SetRootOfTheProject('.')
endfunction
nmap <leader>root :call SetHereTheRoot()<CR>
" 從用戶的輸入獲取指定路徑,並設置爲工程的根目錄
function SetSpecifiedPathTheRoot()
call SetRootOfTheProject(input('請輸入工程根目錄的路徑:'))
endfunction
nmap <leader>xroot :call SetSpecifiedPathTheRoot()<CR>
" lookup file with ignore case
function! LookupFile_IgnoreCaseFunc(pattern)
let _tags = &tags
try
let &tags = eval(g:LookupFile_TagExpr)
let newpattern = '\c' . a:pattern
let tags = taglist(newpattern)
catch
echohl ErrorMsg | echo "Exception: " . v:exception | echohl NONE
return ""
finally
let &tags = _tags
endtry
" Show the matches for what is typed so far.
let files = map(tags, 'v:val["filename"]')
return files
endfunction
let g:LookupFile_LookupFunc = 'LookupFile_IgnoreCaseFunc'
" 使用LookupFile打開文件
nmap <leader>o :LookupFile<CR>
""""""""""""""""""""""""""""""
"NERD File setting
""""""""""""""""""""""""""""""
let g:NERDTree_title="[NERDTree]"
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
let g:netrw_winsize=30
nmap <silent> <leader>fe :Sexplore!<cr>
""""""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
"let Tlist_Show_One_File = 1 "不同時顯示多個文件的tag,只顯示當前文件的
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最後一個窗口,則退出vim
let Tlist_Use_Left_Window = 1 "在右側窗口中顯示taglist窗口
"讓當前不被編輯的文件的方法列表自動摺疊起來
let Tlist_File_Fold_Auto_Close=1
"把taglist窗口放在屏幕的右側,缺省在左側
"let Tlist_Show_Menu = 1
"let Tlist_Auto_Open = 1
""""""""""""""""""""""""""""""
:set tags=./tags
""""""""""""""""""""""""""""""
let g:winManagerWindowLayout='NERDTree|BufExplorer|FileExplorer'
let g:AutoOpenWinManager = 1
" let g:winManagerWindowLayout='NERDTree|BufExplorer|FileExplorer'
nmap <silent> wm :WMToggle<cr>:TlistToggle<cr>
"nmap wm :WMToggle<cr>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.