您的位置:首页 > 运维架构 > Linux

ONE_VimRC_FROM_MY_LINUX

2016-09-04 21:47 337 查看
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>

   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: