" ----------------- Author: Ruchee " ----------------- Email: my@ " ----------------- WebSite: http://www. " ----------------- Date: 2011-11-17 " Ctrl + K --光標移上一行末尾 " Ctrl + H --光標移行首 " Ctrl + L --光標移行尾 " Ctrl + Z --取代ESC模式鍵 [和Lingos快捷鍵有沖突] " Ctrl + S --保存文件 " Ctrl + C --編譯 [支持Gas、C/C++、Java、C#、Haskell、Go] " Ctrl + R --運行 [支持Gas、C/C++、Java、C#、Haskell、Go、Bash、Lua、Perl、Python、Ruby] " Ctrl + ] --轉(zhuǎn)到函數(shù)定義 " Ctrl + T --返回調(diào)用函數(shù) " Ctrl + E --添加注釋 [插入模式下] [添加的是C語言的行注釋,所以適用于C/C++/Java等] " Ctrl + E --一步加載語法模板和作者、時間信息 [非插入模式下] [本質(zhì)是:LoadTemplate和:AuthorInfoDetect的結(jié)合] " <C-P> --單詞補全 " <C-X><C-L> --整行補全 " Tab鍵 --插入模式下的全功能語法結(jié)構(gòu)補全 [snipMate插件] " wm --開啟文檔瀏覽窗口 " \ww --進入vimWiki模式 " za --打開或關(guān)閉當前折疊 " zM --關(guān)閉所有折疊 " zR --打開所有折疊 " :set syntax=cpp --手動選擇語法高亮 [或 :set filetype=cpp] " :%!xxd --轉(zhuǎn)儲二進制文件,以十六進制形式顯示 " :%!xxd -r --還原二進制文件 " ---------- 主要插件詳細用法說明 --------------------- " :Tlist --呼出變量和函數(shù)列表 [TagList插件] " :FencView --查看文件編碼和更改文件編碼 [FencView插件] " :LoadTemplate --呼出語法模板 [Load_Template插件] " :AuthorInfoDetect --添加作者、時間等信息 [NERD_commenter && authorinfo插件] " ---------- a.vim [自動切換C/C++同名頭文件] ---------- " " :A --切換同名頭文件并獨占整個屏幕 " :AS --切換同名頭文件并垂直分屏,頭文件在上 " :AV --切換同名頭文件并水平分割,頭文件在左 " ---------- mark.vim [追蹤高亮指定關(guān)鍵字] ------------ " " \m --normal模式下,在想要高亮的單詞上面敲擊\m即可高亮或取消高亮該單詞 " :Mark --取消所有高亮 " :Mark abc --指定高亮單詞 abc 或取消高亮 abc " ---------- NERDTree [智能文件瀏覽器] ---------------- " " :NERDTree --啟動NERDTree插件 " o [小寫] --切換當前文件或目錄的打開、關(guān)閉狀態(tài) " u --打開上層目錄 " p [小寫] --返回上層目錄 " P [大寫] --返回根目錄 " K --轉(zhuǎn)到當前目錄第一個節(jié)點 " J --轉(zhuǎn)到當前目錄最后的節(jié)點 " m --顯示文件系統(tǒng)菜單 [增、刪、移] " ? --彈出幫助菜單 " q --退出該插件 " 配色方案 colorscheme desert " 灰褐色 "colorscheme django " 灰綠色 "colorscheme hhspring " 土灰色 " 字體、字號 set guifont=Courier\ New:h10 set tabstop=4 " 設(shè)置tab鍵的寬度 set shiftwidth=4 " 換行時行間交錯使用4個空格 set autoindent " 自動對齊 set backspace=2 " 設(shè)置退格鍵可用 set cindent shiftwidth=4 " 自動縮進4空格 set smartindent " 智能自動縮進 set ai! " 設(shè)置自動縮進 set nu! " 顯示行號 "set showmatch " 顯示括號配對情況 set mouse=a " 啟用鼠標 set ruler " 右下角顯示光標位置的狀態(tài)行 set incsearch " 查找book時,當輸入/b時會自動找到 set hlsearch " 開啟高亮顯示結(jié)果 set incsearch " 開啟實時搜索功能 set nowrapscan " 搜索到文件兩端時不重新搜索 set nocompatible " 關(guān)閉兼容模式 set vb t_vb= " 關(guān)閉提示音 "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 " 窗口啟動時自動最大化 "set guioptions-=m " 隱藏菜單欄 set guioptions-=T " 隱藏工具欄 "set guioptions-=L " 隱藏左側(cè)滾動條 "set guioptions-=r " 隱藏右側(cè)滾動條 "set guioptions-=b " 隱藏底部滾動條 "set showtabline=0 " 隱藏Tab欄 endif set writebackup " 設(shè)置無備份文件 set nobackup set autochdir " 設(shè)定文件瀏覽器目錄為當前目錄 "set nowrap " 設(shè)置不自動換行 set foldmethod=syntax " 選擇代碼折疊類型 set foldlevel=100 " 禁止自動折疊 " 每行超過80個的字符用下劃線標示 au BufRead,BufNewFile *.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.hs,*.vim 2match Underlined /.\%81v/ " 編碼設(shè)置 "set fileencoding=utf-8 set fileencodings=utf-8,cp936,gbk,gb18030,big5,latin1 " For Haskell :let hs_highlight_delimiters=1 " 高亮定界符 :let hs_highlight_boolean=1 " 把True和False識別為關(guān)鍵字 :let hs_highlight_types=1 " 把基本類型的名字識別為關(guān)鍵字 :let hs_highlight_more_types=1 " 把更多常用類型識別為關(guān)鍵字 :let hs_highlight_debug=1 " 高亮調(diào)試函數(shù)的名字 :let hs_allow_hash_operator=1 " 阻止把#高亮為錯誤 set laststatus=2 " 開啟狀態(tài)欄信息 set cmdheight=2 " 命令行的高度,默認為1,這里設(shè)為2 " 狀態(tài)行顯示的內(nèi)容 [包括系統(tǒng)平臺、文件類型、坐標、所占比例、時間等] set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %y%r%m%*%=\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} " ######### 括號、引號、中括號等自動匹配 ######### " :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 " ######### 自定義快捷鍵 ######### " " Ctrl + K 將光標移到上一行的末尾 imap ^K <ESC>kA " Ctrl + L 將光標移到行尾 imap ^L <ESC>A " Ctrl + H 將光標移到行首 imap ^H <ESC>I " Ctrl + Z 取代ESC模式鍵 :inoremap ^Z <ESC> " Ctrl + S 保存文件 map ^S <ESC>:w<CR> imap ^S <ESC>:w<CR>a vmap ^S <ESC>:w<CR> " Ctrl + E 一步加載語法模板和作者、時間信息 [非插入模式] map ^E <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi vmap ^E <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi " Ctrl + E 在當前行添加C語言行注釋 [插入模式] imap ^E /* */<ESC>hhi " ######### 第三方插件 ######### " " WinManager 直接輸入 wm 命令即可開啟文件瀏覽窗口 let g:winManagerWindowLayout='FileExplorer' nmap wm :WMToggle<cr> " MiniBufExplorer 多個文件切換 可使用鼠標雙擊相應文件名進行切換 let g:miniBufExplMapWindowNavVim=1 let g:miniBufExplMapWindowNavArrows=1 let g:miniBufExplMapCTabSwitchBufs=1 let g:miniBufExplModSelTarget=1 " TagList 鍵入:Tlist開啟 let Tlist_Show_One_File=1 " 只顯示當前文件的tags let Tlist_Exit_OnlyWindow=1 " 如果Taglist窗口是最后一個窗口則退出Vim let Tlist_Use_Right_Window=1 " 在右側(cè)窗口中顯示 " ctags " ---先在項目頂層目錄執(zhí)行ctags -R,然后打開源文件,在命令模式中執(zhí)行如: " ---set tags=../../tags(這代表tags文件在本目錄的上兩層目錄之中) " ---這樣在函數(shù)名上按 <C-]> 即可轉(zhuǎn)到函數(shù)定義,按 <C-T> 可以返回調(diào)用地址 " ---如果長時間需要在該目錄工作,也可以將tags路徑寫入配置文件 " ---下面是常用開發(fā)環(huán)境的tags路徑,開啟相應的tags即可實現(xiàn)代碼補全、函數(shù)跳轉(zhuǎn) "set tags+=C:\Develop\MinGW\include\tags " For MinGW "set tags+=C:\Develop\GTK\include\tags " For GTK+ set tags+=C:\Develop\Perl\lib\tags " For Perl "set tags+=C:/Develop/Python/Python\ 2.7.2/Lib/tags " For Python " TxtBrowser 高亮TXT文本文件 au BufRead,BufNewFile *.txt setlocal ft=txt " fencview 自動編碼識別 :FencView 查看文件編碼和更改文件編碼 let g:fencview_autodetect=1 " Load_Template 根據(jù)文件后綴自動加載模板,使用:LoadTemplate呼出 let g:template_path = 'D:\Apps\Gvim\vimfiles\template\' " NERD_commenter && authorinfo 自動添加作者、時間等信息,使用:AuthorInfoDetect呼出 let g:vimrc_author='Ruchee' let g:vimrc_email='my@' let g:vimrc_homepage='http://www.' " ######### 一鍵保存和編譯 ######### " " 編譯C源文件 func! CompileGcc() exec "w" let compilecmd="!gcc -Wall -std=c99 " let compileflag="-o %<" exec compilecmd." % ".compileflag endfunc " 編譯C++源文件 func! CompileCpp() exec "w" let compilecmd="!g++ -Wall " let compileflag="-o %<" exec compilecmd." % ".compileflag endfunc " 編譯&鏈接Go源文件 func! CompileGo() exec "w" exec "!8g %" exec "!8l -o %<.exe %<.8" endfunc " 編譯Haskell源文件 func! CompileHaskell() exec "w" let compilecmd="!ghc --make " let compileflag="-o %<" exec compilecmd." % ".compileflag endfunc " 編譯Java源文件 func! CompileJava() exec "w" exec "!javac %" endfunc " 編譯C#源文件 func! CompileCs() exec "w" exec "!csc %" endfunc " 編譯Gas源文件 func! CompileGas() exec "w" exec "!gcc -Wall -ggdb -o %< %" endfunc " 運行Shell源文件 func! RunShell() exec "w" exec "!sh %" endfunc " 運行Lua源文件 func! RunLua() exec "w" exec "!lua %" endfunc " 運行Perl源文件 func! RunPerl() exec "w" exec "!perl %" endfunc " 運行Python源文件 func! RunPython() exec "w" exec "!python %" endfunc " 運行Ruby源文件 func! RunRuby() exec "w" exec "!ruby %" endfunc " 根據(jù)文件類型自動選擇相應的編譯函數(shù) func! CompileCode() exec "w" if &filetype == "c" exec "call CompileGcc()" elseif &filetype == "cpp" exec "call CompileCpp()" elseif &filetype == "go" exec "call CompileGo()" elseif &filetype == "haskell" exec "call CompileHaskell()" elseif &filetype == "java" exec "call CompileJava()" elseif &filetype == "cs" exec "call CompileCs()" elseif &filetype == "asm" exec "call CompileGas()" elseif &filetype == "sh" exec "call RunShell()" elseif &filetype == "lua" exec "call RunLua()" elseif &filetype == "perl" exec "call RunPerl()" elseif &filetype == "python" exec "call RunPython()" elseif &filetype == "ruby" exec "call RunRuby()" endif endfunc " 運行可執(zhí)行文件 func! RunResult() exec "w" if &filetype == "c" exec "! %<" elseif &filetype == "cpp" exec "! %<" elseif &filetype == "go" exec "! %<" elseif &filetype == "haskell" exec "! %<" elseif &filetype == "java" exec "!java %<" elseif &filetype == "cs" exec "! %<" elseif &filetype == "asm" exec "! %<" elseif &filetype == "sh" exec "!sh %<.sh" 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 :call CompileCode()<CR> imap ^C <ESC>:call CompileCode()<CR> vmap ^C <ESC>:call CompileCode()<CR> " Ctrl + R 一鍵保存、運行 map ^R :call RunResult()<CR> imap ^R <ESC>:call RunResult()<CR> vmap ^R <ESC>:call RunResult()<CR> " ######### VimWiki 寫作助手 ######### " " 使用鼠標映射 let g:vimwiki_use_mouse = 1 " 不要將駝峰式詞組作為 Wiki 詞條 let g:vimwiki_camel_case = 0 " 聲明可以在wiki里面使用的HTML標簽 let g:vimwiki_valid_html_tags='b,i,s,u,sub,sup,kbd,br,hr,div,del,code,red,center,left,right,h4,h5,h6,pre' let g:vimwiki_list = [{ \ 'path': 'D:/Apps/Gvim/mysite/wiki', \ 'path_html': 'D:/Apps/Gvim/mysite/html/', \ 'html_header': 'D:/Apps/Gvim/mysite/template/header.html', \ 'html_footer': 'D:/Apps/Gvim/mysite/template/footer.html', \ 'auto_export': 1, \ 'nested_syntaxes': {'Asm': 'asm', 'C': 'c', 'C++': 'cpp','Java': 'java', 'Haskell': 'haskell', 'Lua': 'lua', 'Perl': 'perl', 'Python': 'python', 'Ruby': 'ruby', 'PHP': 'php', 'HTML': 'html', 'Bash': 'sh', 'Vim': 'vim', 'Make': 'make', 'Automake': 'AUTOMAKE'},}] |
|