" ----------------- Author: Ruchee" ----------------- Email: my@ruchee.com" ----------------- WebSite: http://www.ruchee.com" ----------------- 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 + ] --轉到函數定義" Ctrl + T --返回調用函數" Ctrl + E --一步加載語(yǔ)法模板和作者、時(shí)間信息" <C-P> --單詞補全" <C-X><C-L> --整行補全" Tab鍵 --插入模式下的全功能語(yǔ)法結構補全 [snipMate插件]" Shift + Insert --向Vim中粘貼從別處復制的內容" u [小寫(xiě)] --單步復原 [非插入模式]" U [大寫(xiě)] --整行復原 [非插入模式]" jj --保存文件并留在插入模式 [插入模式]" kk --返回Normal模式 [插入模式]" nt --打開(kāi)NERDTree [非插入模式]" tl --打開(kāi)TagList [非插入模式]" za --打開(kāi)或關(guān)閉當前折疊" zM --關(guān)閉所有折疊" zR --打開(kāi)所有折疊" :set syntax=cpp --手動(dòng)選擇語(yǔ)法高亮 [或 :set filetype=cpp]" :%!xxd --轉儲二進(jìn)制文件,以十六進(jìn)制形式顯示" :%!xxd -r --還原二進(jìn)制文件" ---------- 主要插件詳細用法說(shuō)明 ---------------------" :Tlist --呼出變量和函數列表 [TagList插件]" :LoadTemplate --呼出語(yǔ)法模板 [Load_Template插件]" :AuthorInfoDetect --添加作者、時(shí)間等信息 [NERD_commenter && authorinfo插件]" ---------- a.vim [自動(dòng)切換C/C++同名頭文件] ----------"" :A --切換同名頭文件并獨占整個(gè)屏幕" :AS --切換同名頭文件并垂直分屏,頭文件在上" :AV --切換同名頭文件并水平分割,頭文件在左" ---------- mark.vim [追蹤高亮指定關(guān)鍵字] ------------"" \m --normal模式下,在想要高亮的單詞上面敲擊\m即可高亮或取消高亮該單詞" :Mark --取消所有高亮" :Mark abc --指定高亮單詞 abc 或取消高亮 abc" ---------- NERDTree [智能文件瀏覽器] ----------------"" :NERDTree --啟動(dòng)NERDTree插件" o [小寫(xiě)] --切換當前文件或目錄的打開(kāi)、關(guān)閉狀態(tài)" u --打開(kāi)上層目錄" p [小寫(xiě)] --返回上層目錄" P [大寫(xiě)] --返回根目錄" K --轉到當前目錄第一個(gè)節點(diǎn)" J --轉到當前目錄最后的節點(diǎn)" m --顯示文件系統菜單 [增、刪、移]" ? --彈出幫助菜單" q --退出該插件" 將所有以.html結尾的文檔以Django Template語(yǔ)法進(jìn)行渲染" 本配置語(yǔ)句必須放在所有配置的最前面au BufNewFile,BufRead *.html setf htmldjangocolorscheme blackboard " 著(zhù)色模式:藍色背景set guifont=Monaco:h10 " 字體 && 字號set tabstop=4 " 設置tab鍵的寬度set shiftwidth=4 " 換行時(shí)行間交錯使用4個(gè)空格set autoindent " 自動(dòng)對齊set backspace=2 " 設置退格鍵可用set cindent shiftwidth=4 " 自動(dòng)縮進(jìn)4空格set smartindent " 智能自動(dòng)縮進(jìn)set ai! " 設置自動(dòng)縮進(jìn)set nu! " 顯示行號"set showmatch " 顯示括號配對情況set mouse=a " 啟用鼠標set ruler " 右下角顯示光標位置的狀態(tài)行set incsearch " 查找book時(shí),當輸入/b時(shí)會(huì )自動(dòng)找到set hlsearch " 開(kāi)啟高亮顯示結果set incsearch " 開(kāi)啟實(shí)時(shí)搜索功能set nowrapscan " 搜索到文件兩端時(shí)不重新搜索set nocompatible " 關(guān)閉兼容模式set vb t_vb= " 關(guān)閉提示音"set cursorline " 突出顯示當前行set hidden " 允許在有未保存的修改時(shí)切換緩沖區set list " 顯示Tab符,使用一高亮豎線(xiàn)代替set listchars=tab:\|\ ,syntax enable " 打開(kāi)語(yǔ)法高亮syntax on " 開(kāi)啟文件類(lèi)型偵測filetype indent on " 針對不同的文件類(lèi)型采用不同的縮進(jìn)格式filetype plugin on " 針對不同的文件類(lèi)型加載對應的插件filetype plugin indent on " 啟用自動(dòng)補全if has("gui_running") au GUIEnter * simalt ~x " 窗口啟動(dòng)時(shí)自動(dòng)最大化 "winpos 20 20 " 指定窗口出現的位置,坐標原點(diǎn)在屏幕左上角 "set lines=20 columns=90 " 指定窗口大小,lines為高度,columns為寬度 "set guioptions-=m " 隱藏菜單欄 "set guioptions-=T " 隱藏工具欄 "set guioptions-=L " 隱藏左側滾動(dòng)條 "set guioptions-=r " 隱藏右側滾動(dòng)條 "set guioptions-=b " 隱藏底部滾動(dòng)條 "set showtabline=0 " 隱藏Tab欄endifset writebackup " 設置無(wú)備份文件set nobackupset autochdir " 設定文件瀏覽器目錄為當前目錄"set nowrap " 設置不自動(dòng)換行set foldmethod=syntax " 選擇代碼折疊類(lèi)型set foldlevel=100 " 禁止自動(dòng)折疊set laststatus=2 " 開(kāi)啟狀態(tài)欄信息set cmdheight=2 " 命令行的高度,默認為1,這里設為2" 每行超過(guò)80個(gè)的字符用下劃線(xiàn)標示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-8set encoding=utf-8set fileencodings=utf-8,gbk,cp936,latin-1" 解決菜單亂碼source $VIMRUNTIME/delmenu.vimsource $VIMRUNTIME/menu.vim" 解決consle輸出亂碼language messages zh_CN.utf-8" For Haskell:let hs_highlight_delimiters=1 " 高亮定界符:let hs_highlight_boolean=1 " 把True和False識別為關(guān)鍵字:let hs_highlight_types=1 " 把基本類(lèi)型的名字識別為關(guān)鍵字:let hs_highlight_more_types=1 " 把更多常用類(lèi)型識別為關(guān)鍵字:let hs_highlight_debug=1 " 高亮調試函數的名字:let hs_allow_hash_operator=1 " 阻止把#高亮為錯誤" ======= 引號 && 括號自動(dòng)匹配 ======= ":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>ifunction ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endifendf" MiniBufExplorer 多個(gè)文件切換 可使用鼠標雙擊相應文件名進(jìn)行切換let g:miniBufExplMapWindowNavVim=1let g:miniBufExplMapWindowNavArrows=1let g:miniBufExplMapCTabSwitchBufs=1let g:miniBufExplModSelTarget=1" :Tlist 調用TagListlet Tlist_Show_One_File=1 " 只顯示當前文件的tagslet Tlist_Exit_OnlyWindow=1 " 如果Taglist窗口是最后一個(gè)窗口則退出Vimlet Tlist_Use_Right_Window=1 " 在右側窗口中顯示let Tlist_File_Fold_Auto_Close=1 " 自動(dòng)折疊" TxtBrowser 高亮TXT文本文件au BufRead,BufNewFile *.txt setlocal ft=txt" :LoadTemplate 根據文件后綴自動(dòng)加載模板let g:template_path='D:/Apps/Gvim/vimfiles/template/'" :AuthorInfoDetect 自動(dòng)添加作者、時(shí)間等信息,本質(zhì)是NERD_commenter && authorinfo的結合let g:vimrc_author='Ruchee'let g:vimrc_email='my@ruchee.com'let g:vimrc_homepage='http://www.ruchee.com'" 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 一步加載語(yǔ)法模板和作者、時(shí)間信息map <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Giimap <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Givmap <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi" jj 保存文件并留在插入模式 [插入模式]imap jj <ESC>:w<CR>li" kk 返回Normal模式 [插入模式]imap kk <ESC>l" nt 打開(kāi)NERDTree [非插入模式]map nt :NERDTree<CR>" tl 打開(kāi)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" endifendfunc" 運行可執行文件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" endifendfunc" 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> :" 快捷打開(kāi)編輯vimrc文件的鍵盤(pán)綁定map <silent> <leader>ee :e $HOME/.vimrc<cr>autocmd! bufwritepost *.vimrc source $HOME/.vimrc" ^z快速進(jìn)入shellnmap <C-Z> :shell<cr>inoremap <leader>n <esc>" 判斷操作系統if (has("win32") || has("win64") || has("win32unix")) let g:isWin = 1else let g:isWin = 0endif" 判斷是終端還是gvimif has("gui_running") let g:isGUI = 1else let g:isGUI = 0endifset nocompatible " 關(guān)閉兼容模式syntax enable " 語(yǔ)法高亮filetype plugin on " 文件類(lèi)型插件filetype indent onset shortmess=atI " 去掉歡迎界面set autoindentautocmd BufEnter * :syntax sync fromstartset nu " 顯示行號set showcmd " 顯示命令set lz " 當運行宏時(shí),在命令執行完成之前,不重繪屏幕set hid " 可以在沒(méi)有保存的情況下切換bufferset backspace=eol,start,indent set whichwrap+=<,>,h,l " 退格鍵和方向鍵可以換行set incsearch " 增量式搜索set nohlsearch"set hlsearch " 高亮搜索set ignorecase " 搜索時(shí)忽略大小寫(xiě)set magic " 額,自己:h magic吧,一行很難解釋set showmatch " 顯示匹配的括號set nobackup " 關(guān)閉備份set nowbset noswapfile " 不使用swp文件,注意,錯誤退出后無(wú)法恢復set lbr " 在breakat字符處而不是最后一個(gè)字符處斷行set ai " 自動(dòng)縮進(jìn)set si " 智能縮進(jìn)set cindent " C/C++風(fēng)格縮進(jìn)set wildmenu set nofenset fdl=10" tab轉化為4個(gè)字符set expandtabset smarttabset shiftwidth=4set tabstop=4" 不使用beep或flash set vb t_vb=set background=darkset t_Co=256colorscheme xoria256set history=400 " vim記住的歷史操作的數量,默認的是20set autoread " 當文件在外部被修改時(shí),自動(dòng)重新讀取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-=mendif" 設置字符集編碼,默認使用utf8if (g:isWin) let &termencoding=&encoding " 通常win下的encoding為cp936 set fileencodings=utf8,cp936,ucs-bom,latin1else set encoding=utf8 set fileencodings=utf8,gb2312,gb18030,ucs-bom,latin1endif" 狀態(tài)欄set laststatus=2 " 總是顯示狀態(tài)欄highlight StatusLine cterm=bold ctermfg=yellow ctermbg=blue" 獲取當前路徑,將$HOME轉化為~function! CurDir() let curdir = substitute(getcwd(), $HOME, "~", "g") return curdirendfunctionset statusline=[%n]\ %f%m%r%h\ \|\ \ pwd:\ %{CurDir()}\ \ \|%=\|\ %l,%c\ %p%%\ \|\ ascii=%b,hex=%b%{((&fenc==\"\")?\"\":\"\ \|\ \".&fenc)}\ \|\ %{$USER}\ @\ %{hostname()}\ " 第80列往后加下劃線(xiàn)"au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 80 . 'v.\+', -1)" 根據給定方向搜索當前光標下的單詞,結合下面兩個(gè)綁定使用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_regendfunction" 用 */# 向 前/后 搜索光標下的單詞vnoremap <silent> * :call VisualSearch('f')<CR>vnoremap <silent> # :call VisualSearch('b')<CR>" 在文件名上按gf時(shí),在新的tab中打開(kāi)"map gf :tabnew <cfile><cr>" 用c-j,k在buffer之間切換nn <C-J> :bn<cr>nn <C-K> :bp<cr>" Bash(Emacs)風(fēng)格鍵盤(pán)綁定imap <C-e> <END>imap <C-a> <HOME>"imap <C-u> <esc>d0i"imap <C-k> <esc>d$i " 與自動(dòng)補全中的綁定沖突"從系統剪切板中復制,剪切,粘貼map <F7> "+ymap <F8> "+xmap <F9> "+p" 恢復上次文件打開(kāi)位置set viminfo='10,\"100,:20,%,n~/.viminfoau BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif" 刪除buffer時(shí)不關(guān)閉窗口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) endifendfunction" 快捷輸入" 自動(dòng)完成括號和引號inoremap <leader>1 ()<esc>:let leavechar=")"<cr>iinoremap <leader>2 []<esc>:let leavechar="]"<cr>iinoremap <leader>3 {}<esc>:let leavechar="}"<cr>iinoremap <leader>4 {<esc>o}<esc>:let leavechar="}"<cr>Oinoremap <leader>q ''<esc>:let leavechar="'"<cr>iinoremap <leader>w ""<esc>:let leavechar='"'<cr>i" 插件窗口的寬度,如TagList,NERD_tree等,自己設置let s:PlugWinSize = 25" taglist.vim" http://www.vim.org/scripts/script.php?script_id=273" <leader>t 打開(kāi)TagList窗口,窗口在右邊nmap <silent> <leader>t :TlistToggle<cr>"let Tlist_Ctags_Cmd = '/usr/bin/ctags'let Tlist_Show_One_File = 0let Tlist_Exit_OnlyWindow = 1 let Tlist_Use_Right_Window = 1let Tlist_File_Fold_Auto_Close = 1let Tlist_GainFocus_On_ToggleOpen = 0let Tlist_WinWidth = s:PlugWinSizelet Tlist_Auto_Open = 0let Tlist_Display_Prototype = 0"let Tlist_Close_On_Select = 1" OmniCppComplete.vim" http://www.vim.org/scripts/script.php?script_id=1520set completeopt=menulet OmniCpp_ShowPrototypeInAbbr = 1 let OmniCpp_DefaultNamespaces = ["std"] " 逗號分割的字符串let OmniCpp_MayCompleteScope = 1 let OmniCpp_ShowPrototypeInAbbr = 0 let OmniCpp_SelectFirstItem = 2 " c-j自動(dòng)補全,當補全菜單打開(kāi)時(shí),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.vim.org/scripts/script.php?script_id=1218" Toggle單行注釋/“性感”注釋/注釋到行尾/取消注釋map <leader>cc ,c<space>map <leader>cs ,csmap <leader>c$ ,c$map <leader>cu ,cu" NERD tree" http://www.vim.org/scripts/script.php?script_id=1658let NERDTreeShowHidden = 1let NERDTreeWinPos = "left"let NERDTreeWinSize = s:PlugWinSize nmap <leader>n :NERDTreeToggle<cr>" DoxygenToolkit.vim" http://www.vim.org/scripts/script.php?script_id=987" 暫時(shí)沒(méi)有使用" 更新ctags和cscope索引" href: http://www.vimer.cn/2009/10/把vim打造成一個(gè)真正的ide2.html" 稍作修改,提取出DeleteFile函數,修改ctags和cscope執行命令map <F6> :call Do_CsTag()<cr>function! Do_CsTag() let dir = getcwd() "先刪除已有的tags和cscope文件,如果存在且無(wú)法刪除,則報錯。 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!"endfunctionfunction! 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 0endfunction" cscope 綁定if has("cscope") set csto=1 set cst set nocsverb if filereadable("cscope.out") cs add cscope.out endif set csverb " s: C語(yǔ)言符號 g: 定義 d: 這個(gè)函數調用的函數 c: 調用這個(gè)函數的函數 " 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.sourceforge.net/scripts/script.php?script_id=42" http://www.vim.org/scripts/script.php?script_id=197let 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 widthlet g:bufExplorerUseCurrentWindow=1 " Open in new window.autocmd BufWinEnter \[Buf\ List\] setl nonumbernmap <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=0let 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-8set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936set fileencodings=utf-8,ucs-bom,chinese"語(yǔ)言設置set langmenu=zh_CN.UTF-8"設置語(yǔ)法高亮syntax enablesyntax on"設置配色方案colorscheme torte"可以在buffer的任何地方使用鼠標set mouse=aset selection=exclusiveset selectmode=mouse,key"高亮顯示匹配的括號set showmatch"去掉vi一致性set nocompatible"設置縮進(jìn)set tabstop=4set softtabstop=4set shiftwidth=4set autoindentset cindentif &term=="xterm" set t_Co=8 set t_Sb=^[[4%dm set t_Sf=^[[3%dmendif"打開(kāi)文件類(lèi)型自動(dòng)檢測功能filetype on"設置taglistlet Tlist_Show_One_File=0 "顯示多個(gè)文件的tagslet Tlist_File_Fold_Auto_Close=1 "非當前文件,函數列表折疊隱藏let Tlist_Exit_OnlyWindow=1 "在taglist是最后一個(gè)窗口時(shí)退出vimlet Tlist_Use_SingleClick=1 "單擊時(shí)跳轉let Tlist_GainFocus_On_ToggleOpen=1 "打開(kāi)taglist時(shí)獲得輸入焦點(diǎn)let Tlist_Process_File_Always=1 "不管taglist窗口是否打開(kāi),始終解析文件中的tag"設置WinManager插件let g:winManagerWindowLayout='FileExplorer|TagList'nmap wm :WMToggle<cr>map <silent> <F9> :WMToggle<cr> "將F9綁定至WinManager,即打開(kāi)WimManager"設置CSCOPEset cscopequickfix=s-,c-,d-,i-,t-,e- "設定是否使用quickfix窗口顯示cscope結果"設置Grep插件nnoremap <silent> <F3> :Grep<CR>"設置一鍵編譯map <F6> :make<CR>"設置自動(dòng)補全filetype plugin indent on "打開(kāi)文件類(lèi)型檢測set completeopt=longest,menu "關(guān)掉智能補全時(shí)的預覽窗口"啟動(dòng)vim時(shí)如果存在tags則自動(dòng)加載if exists("tags") set tags=./tagsendif"設置按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 endifendfunction"設置默認shellset shell=bash"設置VIM記錄的歷史數set history=400"設置當文件被外部改變的時(shí)侯自動(dòng)讀入文件if exists("&autoread") set autoreadendif"設置ambiwidthset ambiwidth=double"設置文件類(lèi)型set ffs=unix,dos,mac"設置增量搜索模式set incsearch"設置靜音模式set noerrorbellsset novisualbellset t_vb="不要備份文件set nobackupset nowb
聯(lián)系客服