" ----------------- Author: Ruchee " ----------------- Email: my@ " ----------------- WebSite: http://www. " ----------------- Date: 2012-05-01 " Ctrl + H --光標移當前行行首 " Ctrl + J --光標移下一行行首 " Ctrl + K --光標移上一行行尾 " Ctrl + L --光標移當前行行尾 " Ctrl + C --編譯 [支持C/C++、Java、Haskll] " Ctrl + R --運行 [支持C/C++、Java、Haskell、Lua、Perl、Python、Ruby] " Ctrl + ] --轉(zhuǎn)到函數(shù)定義 " Ctrl + T --返回調(diào)用函數(shù) " Ctrl + E --一步加載語法模板和作者、時間信息 " <C-P> --單詞補全 " <C-X><C-L> --整行補全 " Tab鍵 --插入模式下的全功能語法結構補全 [snipMate插件] " Shift + Insert --向Vim中粘貼從別處復制的內(nèi)容 " u [小寫] --單步復原 [非插入模式] " U [大寫] --整行復原 [非插入模式] " jj --保存文件并留在插入模式 [插入模式] " kk --返回Normal模式 [插入模式] " nt --打開NERDTree [非插入模式] " tl --打開TagList [非插入模式] " za --打開或關閉當前折疊 " zM --關閉所有折疊 " zR --打開所有折疊 " :set syntax=cpp --手動選擇語法高亮 [或 :set filetype=cpp] " :%!xxd --轉(zhuǎn)儲二進制文件,以十六進制形式顯示 " :%!xxd -r --還原二進制文件 " ---------- 主要插件詳細用法說明 --------------------- " :Tlist --呼出變量和函數(shù)列表 [TagList插件] " :LoadTemplate --呼出語法模板 [Load_Template插件] " :AuthorInfoDetect --添加作者、時間等信息 [NERD_commenter && authorinfo插件] " ---------- a.vim [自動切換C/C++同名頭文件] ---------- " " :A --切換同名頭文件并獨占整個屏幕 " :AS --切換同名頭文件并垂直分屏,頭文件在上 " :AV --切換同名頭文件并水平分割,頭文件在左 " ---------- mark.vim [追蹤高亮指定關鍵字] ------------ " " \m --normal模式下,在想要高亮的單詞上面敲擊\m即可高亮或取消高亮該單詞 " :Mark --取消所有高亮 " :Mark abc --指定高亮單詞 abc 或取消高亮 abc " ---------- NERDTree [智能文件瀏覽器] ---------------- " " :NERDTree --啟動NERDTree插件 " o [小寫] --切換當前文件或目錄的打開、關閉狀態(tài) " u --打開上層目錄 " p [小寫] --返回上層目錄 " P [大寫] --返回根目錄 " K --轉(zhuǎn)到當前目錄第一個節(jié)點 " J --轉(zhuǎn)到當前目錄最后的節(jié)點 " m --顯示文件系統(tǒng)菜單 [增、刪、移] " ? --彈出幫助菜單 " q --退出該插件 " 將所有以.html結尾的文檔以Django Template語法進行渲染 " 本配置語句必須放在所有配置的最前面 au BufNewFile,BufRead *.html setf htmldjango colorscheme blackboard " 著色模式:藍色背景 set guifont=Monaco:h10 " 字體 && 字號 set tabstop=4 " 設置tab鍵的寬度 set shiftwidth=4 " 換行時行間交錯使用4個空格 set autoindent " 自動對齊 set backspace=2 " 設置退格鍵可用 set cindent shiftwidth=4 " 自動縮進4空格 set smartindent " 智能自動縮進 set ai! " 設置自動縮進 set nu! " 顯示行號 "set showmatch " 顯示括號配對情況 set mouse=a " 啟用鼠標 set ruler " 右下角顯示光標位置的狀態(tài)行 set incsearch " 查找book時,當輸入/b時會自動找到 set hlsearch " 開啟高亮顯示結果 set incsearch " 開啟實時搜索功能 set nowrapscan " 搜索到文件兩端時不重新搜索 set nocompatible " 關閉兼容模式 set vb t_vb= " 關閉提示音 "set cursorline " 突出顯示當前行 set hidden " 允許在有未保存的修改時切換緩沖區(qū) set list " 顯示Tab符,使用一高亮豎線代替 set listchars=tab:\|\ , syntax enable " 打開語法高亮 syntax on " 開啟文件類型偵測 filetype indent on " 針對不同的文件類型采用不同的縮進格式 filetype plugin on " 針對不同的文件類型加載對應的插件 filetype plugin indent on " 啟用自動補全 if has("gui_running") au GUIEnter * simalt ~x " 窗口啟動時自動最大化 "winpos 20 20 " 指定窗口出現(xiàn)的位置,坐標原點在屏幕左上角 "set lines=20 columns=90 " 指定窗口大小,lines為高度,columns為寬度 "set guioptions-=m " 隱藏菜單欄 "set guioptions-=T " 隱藏工具欄 "set guioptions-=L " 隱藏左側(cè)滾動條 "set guioptions-=r " 隱藏右側(cè)滾動條 "set guioptions-=b " 隱藏底部滾動條 "set showtabline=0 " 隱藏Tab欄 endif set writebackup " 設置無備份文件 set nobackup set autochdir " 設定文件瀏覽器目錄為當前目錄 "set nowrap " 設置不自動換行 set foldmethod=syntax " 選擇代碼折疊類型 set foldlevel=100 " 禁止自動折疊 set laststatus=2 " 開啟狀態(tài)欄信息 set cmdheight=2 " 命令行的高度,默認為1,這里設為2 " 每行超過80個的字符用下劃線標示 au BufRead,BufNewFile *.s,*.asm,*.h,*.c,*.cpp,*.cc,*.java,*.cs,*.erl,*.hs,*.sh,*.lua,*.pl,*.pm,*.php,*.py,*.rb,*.erb,*.vim,*.js,*.css,*.xml,*.html,*.xhtml 2match Underlined /.\%81v/ " 設置編碼 set fenc=utf-8 set encoding=utf-8 set fileencodings=utf-8,gbk,cp936,latin-1 " 解決菜單亂碼 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim " 解決consle輸出亂碼 language messages zh_CN.utf-8 " For Haskell :let hs_highlight_delimiters=1 " 高亮定界符 :let hs_highlight_boolean=1 " 把True和False識別為關鍵字 :let hs_highlight_types=1 " 把基本類型的名字識別為關鍵字 :let hs_highlight_more_types=1 " 把更多常用類型識別為關鍵字 :let hs_highlight_debug=1 " 高亮調(diào)試函數(shù)的名字 :let hs_allow_hash_operator=1 " 阻止把#高亮為錯誤 " ======= 引號 && 括號自動匹配 ======= " :inoremap ( ()<ESC>i :inoremap ) <c-r>=ClosePair(')')<CR> :inoremap { {}<ESC>i :inoremap } <c-r>=ClosePair('}')<CR> :inoremap [ []<ESC>i :inoremap ] <c-r>=ClosePair(']')<CR> ":inoremap < <><ESC>i ":inoremap > <c-r>=ClosePair('>')<CR> :inoremap " ""<ESC>i :inoremap ' ''<ESC>i :inoremap ` ``<ESC>i function ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endf " MiniBufExplorer 多個文件切換 可使用鼠標雙擊相應文件名進行切換 let g:miniBufExplMapWindowNavVim=1 let g:miniBufExplMapWindowNavArrows=1 let g:miniBufExplMapCTabSwitchBufs=1 let g:miniBufExplModSelTarget=1 " :Tlist 調(diào)用TagList let Tlist_Show_One_File=1 " 只顯示當前文件的tags let Tlist_Exit_OnlyWindow=1 " 如果Taglist窗口是最后一個窗口則退出Vim let Tlist_Use_Right_Window=1 " 在右側(cè)窗口中顯示 let Tlist_File_Fold_Auto_Close=1 " 自動折疊 " TxtBrowser 高亮TXT文本文件 au BufRead,BufNewFile *.txt setlocal ft=txt " :LoadTemplate 根據(jù)文件后綴自動加載模板 let g:template_path='D:/Apps/Gvim/vimfiles/template/' " :AuthorInfoDetect 自動添加作者、時間等信息,本質(zhì)是NERD_commenter && authorinfo的結合 let g:vimrc_author='Ruchee' let g:vimrc_email='my@' let g:vimrc_homepage='http://www.' " Ctrl + H 將光標移到當前行的行首 imap <c-h> <ESC>I " Ctrl + J 將光標移到下一行的行首 imap <c-j> <ESC>jI " Ctrl + K 將光標移到上一行的末尾 imap <c-k> <ESC>kA " Ctrl + L 將光標移到當前行的行尾 imap <c-l> <ESC>A " Ctrl + E 一步加載語法模板和作者、時間信息 map <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi imap <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi vmap <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi " jj 保存文件并留在插入模式 [插入模式] imap jj <ESC>:w<CR>li " kk 返回Normal模式 [插入模式] imap kk <ESC>l " nt 打開NERDTree [非插入模式] map nt :NERDTree<CR> " tl 打開Taglist [非插入模式] map tl :Tlist<CR><c-l> " ======= 編譯 && 運行 ======= " " 編譯源文件 func! CompileCode() exec "w" if &filetype == "c" exec "!gcc -Wall -std=c99 %<.c -o %<" elseif &filetype == "cpp" exec "!g++ -Wall -std=c++98 %<.cpp -o %<" elseif &filetype == "java" exec "!javac %<.java" elseif &filetype == "haskell" exec "!ghc --make %<.hs -o %<" elseif &filetype == "lua" exec "!lua %<.lua" elseif &filetype == "perl" exec "!perl %<.pl" elseif &filetype == "python" exec "!python %<.py" elseif &filetype == "ruby" exec "!ruby %<.rb" endif endfunc " 運行可執(zhí)行文件 func! RunCode() exec "w" if &filetype == "c" || &filetype == "cpp" || &filetype == "haskell" exec "! %<.exe" elseif &filetype == "java" exec "!java %<" elseif &filetype == "lua" exec "!lua %<.lua" elseif &filetype == "perl" exec "!perl %<.pl" elseif &filetype == "python" exec "!python %<.py" elseif &filetype == "ruby" exec "!ruby %<.rb" endif endfunc " Ctrl + C 一鍵保存、編譯 map <c-c> :call CompileCode()<CR> imap <c-c> <ESC>:call CompileCode()<CR> vmap <c-c> <ESC>:call CompileCode()<CR> " Ctrl + R 一鍵保存、運行 map <c-r> :call RunCode()<CR> imap <c-r> <ESC>:call RunCode()<CR> vmap <c-r> <ESC>:call RunCode()<CR> let mapleader = ";" " 比較習慣用;作為命令前綴,右手小拇指直接能按到 " 把空格鍵映射成: nmap <space> : " 快捷打開編輯vimrc文件的鍵盤綁定 map <silent> <leader>ee :e $HOME/.vimrc<cr> autocmd! bufwritepost *.vimrc source $HOME/.vimrc " ^z快速進入shell nmap <C-Z> :shell<cr> inoremap <leader>n <esc> " 判斷操作系統(tǒng) if (has("win32") || has("win64") || has("win32unix")) let g:isWin = 1 else let g:isWin = 0 endif " 判斷是終端還是gvim if has("gui_running") let g:isGUI = 1 else let g:isGUI = 0 endif set nocompatible " 關閉兼容模式 syntax enable " 語法高亮 filetype plugin on " 文件類型插件 filetype indent on set shortmess=atI " 去掉歡迎界面 set autoindent autocmd BufEnter * :syntax sync fromstart set nu " 顯示行號 set showcmd " 顯示命令 set lz " 當運行宏時,在命令執(zhí)行完成之前,不重繪屏幕 set hid " 可以在沒有保存的情況下切換buffer set backspace=eol,start,indent set whichwrap+=<,>,h,l " 退格鍵和方向鍵可以換行 set incsearch " 增量式搜索 set nohlsearch "set hlsearch " 高亮搜索 set ignorecase " 搜索時忽略大小寫 set magic " 額,自己:h magic吧,一行很難解釋 set showmatch " 顯示匹配的括號 set nobackup " 關閉備份 set nowb set noswapfile " 不使用swp文件,注意,錯誤退出后無法恢復 set lbr " 在breakat字符處而不是最后一個字符處斷行 set ai " 自動縮進 set si " 智能縮進 set cindent " C/C++風格縮進 set wildmenu set nofen set fdl=10 " tab轉(zhuǎn)化為4個字符 set expandtab set smarttab set shiftwidth=4 set tabstop=4 " 不使用beep或flash set vb t_vb= set background=dark set t_Co=256 colorscheme xoria256 set history=400 " vim記住的歷史操作的數(shù)量,默認的是20 set autoread " 當文件在外部被修改時,自動重新讀取 set mouse=n " 在所有模式下都允許使用鼠標,還可以是n,v,i,c等 "在gvim中高亮當前行 if (g:isGUI) set cursorline colorscheme wombat hi cursorline guibg=#333333 hi CursorColumn guibg=#333333 "set guifont=Consolas\ 10 "set guifontwide=Consolas\ 10 set guifont=DejaVu\ Sans\ Mono\ 10 set gfw=DejaVu\ Sans\ Mono\ 10 " 不顯示toolbar set guioptions-=T " 不顯示菜單欄 "set guioptions-=m endif " 設置字符集編碼,默認使用utf8 if (g:isWin) let &termencoding=&encoding " 通常win下的encoding為cp936 set fileencodings=utf8,cp936,ucs-bom,latin1 else set encoding=utf8 set fileencodings=utf8,gb2312,gb18030,ucs-bom,latin1 endif " 狀態(tài)欄 set laststatus=2 " 總是顯示狀態(tài)欄 highlight StatusLine cterm=bold ctermfg=yellow ctermbg=blue " 獲取當前路徑,將$HOME轉(zhuǎn)化為~ function! CurDir() let curdir = substitute(getcwd(), $HOME, "~", "g") return curdir endfunction set statusline=[%n]\ %f%m%r%h\ \|\ \ pwd:\ %{CurDir()}\ \ \|%=\|\ %l,%c\ %p%%\ \|\ ascii=%b,hex=%b%{((&fenc==\"\")?\"\":\"\ \|\ \".&fenc)}\ \|\ %{$USER}\ @\ %{hostname()}\ " 第80列往后加下劃線 "au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 80 . 'v.\+', -1) " 根據(jù)給定方向搜索當前光標下的單詞,結合下面兩個綁定使用 function! VisualSearch(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "<cr>" else execute "normal /" . l:pattern . "<cr>" endif let @/ = l:pattern let @" = l:saved_reg endfunction " 用 */# 向 前/后 搜索光標下的單詞 vnoremap <silent> * :call VisualSearch('f')<CR> vnoremap <silent> # :call VisualSearch('b')<CR> " 在文件名上按gf時,在新的tab中打開 "map gf :tabnew <cfile><cr> " 用c-j,k在buffer之間切換 nn <C-J> :bn<cr> nn <C-K> :bp<cr> " Bash(Emacs)風格鍵盤綁定 imap <C-e> <END> imap <C-a> <HOME> "imap <C-u> <esc>d0i "imap <C-k> <esc>d$i " 與自動補全中的綁定沖突 "從系統(tǒng)剪切板中復制,剪切,粘貼 map <F7> "+y map <F8> "+x map <F9> "+p " 恢復上次文件打開位置 set viminfo='10,\"100,:20,%,n~/.viminfo au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif " 刪除buffer時不關閉窗口 command! Bclose call <SID>BufcloseCloseIt() function! <SID>BufcloseCloseIt() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") if buflisted(l:alternateBufNum) buffer # else bnext endif if bufnr("%") == l:currentBufNum new endif if buflisted(l:currentBufNum) execute("bdelete! ".l:currentBufNum) endif endfunction " 快捷輸入 " 自動完成括號和引號 inoremap <leader>1 ()<esc>:let leavechar=")"<cr>i inoremap <leader>2 []<esc>:let leavechar="]"<cr>i inoremap <leader>3 {}<esc>:let leavechar="}"<cr>i inoremap <leader>4 {<esc>o}<esc>:let leavechar="}"<cr>O inoremap <leader>q ''<esc>:let leavechar="'"<cr>i inoremap <leader>w ""<esc>:let leavechar='"'<cr>i " 插件窗口的寬度,如TagList,NERD_tree等,自己設置 let s:PlugWinSize = 25 " taglist.vim " http://www./scripts/script.php?script_id=273 " <leader>t 打開TagList窗口,窗口在右邊 nmap <silent> <leader>t :TlistToggle<cr> "let Tlist_Ctags_Cmd = '/usr/bin/ctags' let Tlist_Show_One_File = 0 let Tlist_Exit_OnlyWindow = 1 let Tlist_Use_Right_Window = 1 let Tlist_File_Fold_Auto_Close = 1 let Tlist_GainFocus_On_ToggleOpen = 0 let Tlist_WinWidth = s:PlugWinSize let Tlist_Auto_Open = 0 let Tlist_Display_Prototype = 0 "let Tlist_Close_On_Select = 1 " OmniCppComplete.vim " http://www./scripts/script.php?script_id=1520 set completeopt=menu let OmniCpp_ShowPrototypeInAbbr = 1 let OmniCpp_DefaultNamespaces = ["std"] " 逗號分割的字符串 let OmniCpp_MayCompleteScope = 1 let OmniCpp_ShowPrototypeInAbbr = 0 let OmniCpp_SelectFirstItem = 2 " c-j自動補全,當補全菜單打開時,c-j,k上下選擇 imap <expr> <c-j> pumvisible()?"\<C-N>":"\<C-X><C-O>" imap <expr> <c-k> pumvisible()?"\<C-P>":"\<esc>" " f:文件名補全,l:行補全,d:字典補全,]:tag補全 imap <C-]> <C-X><C-]> imap <C-F> <C-X><C-F> imap <C-D> <C-X><C-D> imap <C-L> <C-X><C-L> " NERD_commenter.vim " http://www./scripts/script.php?script_id=1218 " Toggle單行注釋/“性感”注釋/注釋到行尾/取消注釋 map <leader>cc ,c<space> map <leader>cs ,cs map <leader>c$ ,c$ map <leader>cu ,cu " NERD tree " http://www./scripts/script.php?script_id=1658 let NERDTreeShowHidden = 1 let NERDTreeWinPos = "left" let NERDTreeWinSize = s:PlugWinSize nmap <leader>n :NERDTreeToggle<cr> " DoxygenToolkit.vim " http://www./scripts/script.php?script_id=987 " 暫時沒有使用 " 更新ctags和cscope索引 " href: http://www./2009/10/把vim打造成一個真正的ide2.html " 稍作修改,提取出DeleteFile函數(shù),修改ctags和cscope執(zhí)行命令 map <F6> :call Do_CsTag()<cr> function! Do_CsTag() let dir = getcwd() "先刪除已有的tags和cscope文件,如果存在且無法刪除,則報錯。 if ( DeleteFile(dir, "tags") ) return endif if ( DeleteFile(dir, "cscope.files") ) return endif if ( DeleteFile(dir, "cscope.out") ) return endif if(executable('ctags')) silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." endif if(executable('cscope') && has("cscope") ) if(g:isWin) silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files" else silent! execute "!find . -iname '*.[ch]' -o -name '*.cpp' > cscope.files" endif silent! execute "!cscope -b" execute "normal :" if filereadable("cscope.out") execute "cs add cscope.out" endif endif " 刷新屏幕 execute "redr!" endfunction function! DeleteFile(dir, filename) if filereadable(a:filename) if (g:isWin) let ret = delete(a:dir."\\".a:filename) else let ret = delete("./".a:filename) endif if (ret != 0) echohl WarningMsg | echo "Failed to delete ".a:filename | echohl None return 1 else return 0 endif endif return 0 endfunction " cscope 綁定 if has("cscope") set csto=1 set cst set nocsverb if filereadable("cscope.out") cs add cscope.out endif set csverb " s: C語言符號 g: 定義 d: 這個函數(shù)調(diào)用的函數(shù) c: 調(diào)用這個函數(shù)的函數(shù) " t: 文本 e: egrep模式 f: 文件 i: include本文件的文件 nmap <leader>ss :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR> nmap <leader>sg :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <leader>sc :cs find c <C-R>=expand("<cword>")<CR><CR>:copen<CR> nmap <leader>st :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR> nmap <leader>se :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR> nmap <leader>sf :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR> nmap <leader>si :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR> nmap <leader>sd :cs find d <C-R>=expand("<cword>")<CR><CR>:copen<CR> endif " Quick Fix 設置 map <F3> :cw<cr> map <F4> :cp<cr> map <F5> :cn<cr> " Buffers Explorer (需要genutils.vim) " http://vim./scripts/script.php?script_id=42 " http://www./scripts/script.php?script_id=197 let g:bufExplorerDefaultHelp=0 " Do not show default help. let g:bufExplorerShowRelativePath=1 " Show relative paths. let g:bufExplorerSortBy='mru' " Sort by most recently used. let g:bufExplorerSplitRight=0 " Split left. let g:bufExplorerSplitVertical=1 " Split vertically. let g:bufExplorerSplitVertSize = s:PlugWinSize " Split width let g:bufExplorerUseCurrentWindow=1 " Open in new window. autocmd BufWinEnter \[Buf\ List\] setl nonumber nmap <silent> <Leader>b :BufExplorer<CR> " Vimwiki配置 let g:vimwiki_list = [{'path': '~/Dropbox/MyWiki/my_site/', \ 'path-html': '~/Dropbox/MyWiki/my_site_html/', \ 'html-header': '~/Dropbox/MyWiki/templates/header.tpl', \ 'html-footer': '~/Dropbox/MyWiki/templates/footer.tpl'}] let g:vimwiki_camel_case=0 let wiki = {} let wiki.path = '~/Dropbox/MyWiki/my_site/' let wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp'} let g:vimwiki_list = [wiki] "pythoncomplete配置 autocmd filetype python set omnifunc=pythoncomplete#Complete runtime! debian.vim "設置編碼 set encoding=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 set fileencodings=utf-8,ucs-bom,chinese "語言設置 set langmenu=zh_CN.UTF-8 "設置語法高亮 syntax enable syntax on "設置配色方案 colorscheme torte "可以在buffer的任何地方使用鼠標 set mouse=a set selection=exclusive set selectmode=mouse,key "高亮顯示匹配的括號 set showmatch "去掉vi一致性 set nocompatible "設置縮進 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 "打開文件類型自動檢測功能 filetype on "設置taglist let Tlist_Show_One_File=0 "顯示多個文件的tags let Tlist_File_Fold_Auto_Close=1 "非當前文件,函數(shù)列表折疊隱藏 let Tlist_Exit_OnlyWindow=1 "在taglist是最后一個窗口時退出vim let Tlist_Use_SingleClick=1 "單擊時跳轉(zhuǎn) 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 "設置CSCOPE set 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=./tags endif "設置按F12就更新tags的方法 map <F12> :call Do_CsTag()<CR> nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<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>:copen<CR> nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR> nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR> nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR> nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR> nmap <C-@>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 endif endfunction "設置默認shell set shell=bash "設置VIM記錄的歷史數(shù) set history=400 "設置當文件被外部改變的時侯自動讀入文件 if exists("&autoread") set autoread endif "設置ambiwidth set ambiwidth=double "設置文件類型 set ffs=unix,dos,mac "設置增量搜索模式 set incsearch "設置靜音模式 set noerrorbells set novisualbell set t_vb= "不要備份文件 set nobackup set nowb |
|