set awa set ai set showcmd set nocompatible set ruler set acd " automatically change directory. " 去掉煩人的編輯提示 set nobackup set writebackup set noswf " 去掉煩人的交換文件. 09/11/06 thinkhy "set backupskip " set isk="@,48-57,_,128-167,224-235,〗,〖" 這個(gè)設(shè)置沒成功,暫不清楚原因。 09/11/20 thinkhy " [Added by thinkhy 10/01/15] " 不讓會話文件所在的目錄會成為當(dāng)前目錄,保證mksession后能正確打開文件 set ssop-=sesdir " [Added by thinkhy 10/04/02] " 文件補(bǔ)全時(shí)不做反斜扛替換 set shellslash syntax enable set cindent inoremap <CR> <ESC> inoremap <CR> <ESC> nmap <Space> o<ESC> nmap <F2> :w<CR> imap <F2> <ESC>:w<CR> nmap <F3> <C-w>w imap <F3> <ESC><C-w>w nmap <F4> <C-w>c imap <F4> <ESC><C-w>c " 改變窗口大小 map <Down> <ESC>:winc-<CR> map <Up> <ESC>:winc+<CR> map <Left> <ESC>:winc<<CR> map <Right> <ESC>:winc><CR> " 改變編輯窗口 map <M-k> <ESC><C-w>k map <M-j> <ESC><C-w>j map <M-n> <ESC><C-w>h map <M-l> <ESC><C-w>l " 在多個(gè)文件中g(shù)rep當(dāng)前光標(biāo)下的單詞 090323 thinkhy " 加上java文件 [09/10/22 thinkhy] " 加js文件 [09/01/19 thinkhy] map gr :vimgrep <cword> *.cpp *.c *.h *.java *.js *.rc<CR> map gR :vimgrep <cword> **/*.cpp **/*.c **/*.h *.java *.js *.rc<CR> " map兩個(gè)最常用的操作 系統(tǒng)剪貼板的復(fù)制粘貼[10/03/10 thinkhy] nmap <c-k> "+p vmap <c-k> "+p imap <c-k> <c-r>+ noremap <c-y> "+y " map <C-y> <ESC>"+ya " 命令模式映射 " 1 建立C++工程的tags文件 " cmap ctags !ctags -R --kinds-c++ --fields=+iaS --extra=+q --language-force=c++ autocmd FileType c,cpp,h,xml,xsd,xsl :setlocal tabstop=4 expandtab autocmd FileType c,cpp,h :let @g='vimgrep // *.c *.cpp *.h' autocmd FileType xml :let @h='<?xml version="1.0" encoding="utf-8"?> ' autocmd FileType xml,html :nmap <F12> :%!xmllint --format %<CR> autocmd FileType xml,html :imap <F12> <ESC>:%!xmllint --format %<CR> " 書版 09/10/30 thinkhy autocmd BufNewFile,BufRead *.fbd :syntax on runtime! syntax/fbd.vim "au Syntax fbd runtime! syntax/fbd.vim " 設(shè)置用于lookup插件的filetags let g:LookupFile_TagExpr='"filenametags"' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Code Tags """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " MFC tags And Windows API tags autocmd FileType c,cc,cpp,h :setlocal tags+=d:/work/tags/mfc/tags " wine 模擬windows內(nèi)核代碼 autocmd FileType c,cc,cpp,h :setlocal tags+=d:/work/tags/winapi/windows/tags " XTP控件源代碼 autocmd FileType c,cc,cpp,h :setlocal tags+=d:/work/tags/third_part/tags autocmd FileType c,cc,cpp,h :setlocal path=.,D:/work/tags/mfc/include,D:/work/tags/winapi/Include_HY,D:/work/tags/third_part " WEB代碼直接 autocmd FileType javascript,html,htm :set tags+=d:/work/tags/WebKit/tags "*************************************************************************** " For Plugin """"""""""""""""""""" " 1> Taglist """"""""""""""""""""" let Tlist_Show_One_File=1 let Tlist_Exit_OnlyWindow=1 nmap <F8> :TlistToggle<CR> imap <F8> <ESC>:TlistToggle<CR> """"""""""""""""""""" " 2> A """"""""""""""""""""" nmap <F7> :A<CR> imap <F7> <ESC>:A<CR> """"""""""""""""""""" " 3> lookupfile """"""""""""""""""""" let g:LookupFile_MinPatLength = 3 " 最少輸入3個(gè)字開始匹配 let g:LookupFile_PreserveLastPattern = 3 " 不保存上次查找的字符串 let g:LookupFile_PreservePatternHistory = 1 " 保存查找歷史 let g:LookupFile_AlwaysAcceptFirst = 1 " 回車打開第一個(gè)匹配項(xiàng)目 let g:LookupFile_AllowNewFiles = 0 " 不允許創(chuàng)建不存在的文件 " 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' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""" " BufExplorer 09/07/18 在水木VIM版向flw收的技巧 """"""""""""""""""""" nmap F :BufExplorer<CR> """"""""""""""""""""" " 4> miniBufexplore 這個(gè)插件不好用,暫時(shí)撤掉 09/11/26 """"""""""""""""""""" " let g:miniBufExplMapWindowNavVim = 1 " let g:miniBufExplMapWindowNavArrows = 1 " let g:miniBufExplMapCTabSwitchBufs = 1 " let g:miniBufExplModSelTarget = 1 """""""""""""""""""""""" " 發(fā)信人: SKPotti (冰封?晚飯無助), 信區(qū): VIM " 標(biāo) 題: Re: 請問大家能用VIM打開附件中的文件嗎? " 發(fā)信站: 水木社區(qū) (Wed Feb 3 12:10:39 2010), 站內(nèi) " fencview.vim " 解決大部分的編碼問題 " enc建議設(shè)成utf-8 " 感謝SKPotti,幫我解決了Windows里打開utf-8的問題 " 但utf-16的問題仍然沒解決 " : FencAutoDetect let g:fencview_autodetect = 1 "************************************************************************ " 在水木收的一些技巧 ">================================================= ">================================================= " [ Added by thinkhy 2010年 01月 02日 星期六 19:54:24 CST] " 水木VIM版 15322貼 "發(fā)信人: flw (梨花小蓓蕾), 信區(qū): VIM "標(biāo) 題: 分享幾個(gè)我自認(rèn)為比較得意的自定義快捷鍵 "發(fā)信站: 水木社區(qū) (Mon Dec 28 10:34:46 2009), 站內(nèi) " 換標(biāo)簽頁 nmap <C-N> :tabnext<CR> nmap <C-P> :tabprev<CR> " 換窗口 nmap <silent><TAB> <c-w>w:set cursorline<CR>:100sl m<CR>:set nocursorline<CR> nmap <silent><S-TAB> <c-w>p:set cursorline<CR>:100sl m<CR>:set nocursorline<CR> function! HelpHelper( where ) " 先拿下光標(biāo)下的文字 let l:word = expand( "<cWORD>" ) " 再取出疑似函數(shù)名/模塊名的部分和疑似方法的部分 " /([_a-zA-Z0-9:]/+/)/(->/([_a-zA-Z0-9]/+/)/)/? let l:lists = matchlist( l:word, "//([_a-zA-Z0-9:]//+//)//(->//([_a-zA-Z0-9]//+//)//)//?" ) let l:name = l:lists[1] let l:method = l:lists[3] let l:progList = [] if &ft == "perl" if match( l:name, "::" ) != -1 " 函數(shù)里是不可能有 :: 的,不用想了,一定是模塊 let l:progList += [ [ "perldoc -u ", "pod" ] ] elseif strlen( l:method ) " 有方法的,一定是模塊了 let l:progList += [ [ "perldoc -u ", "pod" ] ] elseif match( l:name, "[A-Z]" ) != -1 " 有大寫字母,那一定是模塊了,Perl buildin 函數(shù)的名稱全都是小寫字母的 let l:progList += [ [ "perldoc -u ", "pod" ] ] else " 剩下的,有可能是函數(shù),也有可能是模塊, " 但是考慮到這樣的模塊較少,因此先優(yōu)先查函數(shù) let l:progList += [ [ "perldoc -u -f ", "pod" ], [ "perldoc -u ", "pod" ] ] endif endif if &ft == "python" let l:progList += [ [ "python -c /"import sys; a = sys.argv[-1]; b = a.find('.') > -1 and 1 or 0; m = b == 1 and '.'.join(a.split('.')[:-1]) or a; exec( 'import '+m+';help('+a+')' )/" ", "man" ] ] endif if &ft == "erlang" if match( l:name, ":" ) != -1 " erlang 的模塊方法 let l:lists = matchlist( l:name, "//([_a-zA-Z0-9:]//+//)://([_a-zA-Z0-9]//+//)" ) let l:name = l:lists[1] let l:method = l:lists[2] endif let l:progList += [ [ "PAGER=/"col -b/" erl -man ", "man" ] ] endif let l:progList += [ [ "PAGER=/"col -b/" man 3 ", "man" ] ] let l:progList += [ [ "PAGER=/"col -b/" man 2 ", "man" ] ] let l:progList += [ [ "PAGER=/"col -b/" man ", "man" ] ] let l:found = 0 " 下面調(diào)用外部命令,取幫助信息 " [Added by thinkhy 10/01/02] if &ft == "vim" echomsg "I am vim" try execute " h " . l:word catch /foo/ endtry execute "wincmd p" return endif " [End thinkhy] for l:prog in l:progList let l:progName = l:prog[0] let l:fileType = l:prog[1] let l:cmd = l:progName . l:name let l:lines = system( l:cmd ) if !v:shell_error if a:where ==? "inNewTab" tabe elseif a:where ==? "Vertical" rightbelow new else above new endif set buftype = nofile set ts = 8 execute "set ft=" . l:fileType call append( 0, split( l:lines, "/n" ) ) normal gg if strlen(l:method) " 跳轉(zhuǎn)到方法 if l:fileType == "pod" " regex: /(=item/d*/s/+/)/@<= /> call search( "//(=item//d*//s//+//)//@<=" . l:method . "//>" ) elseif l:fileType == "man" " regex: /(^/s/+/)/@<=l:method/> call search( "//(^//s//+//)//@<=" . l:method . "//>" ) endif endif let l:found = 1 break endif endfor if !l:found echohl ErrorMsg | echomsg "^_^ 沒有幫助信息。" | echohl None endif endfunction " vim 內(nèi)打開 man/perldoc/erl -man/python help autocmd FileType c,perl,erlang,python,vim nmap <silent> K :call HelpHelper( "" )<CR> autocmd FileType c,perl,erlang,python,vim nmap <silent> gK :call HelpHelper( "InNewTab" )<CR> |
|