set nocompatible javascript
set tabstop=4 set shiftwidth=4 set backspace=2 set showmatch set mouse=a set hlsearch set nocompatible set guifont=Consolas:h16 set syntax=on syntax enable set encoding=utf-8 set termencoding=utf-8 set ai! set nu set ruler set hidden set list set nobackup set autochdir " 設置編碼 set fenc=utf-8 set encoding=utf-8 set fileencodings=utf-8,chinese,latin-1 if has("win32") set fileencoding=chinese else set fileencoding=utf-8 endif "解決中文菜單亂碼 set langmenu=zh_CN.utf-8 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim "解決console輸出亂碼 language messages zh_cn.utf-8 au BufRead,BufNewFile *.js set syntax=jquery "添加jquery配色支持 let b:javascript_fold=1 " 打開javascript摺疊 let javascript_enable_domhtmlcss=1 " 打開javascript對dom、html "這是我偷來的文件, " ======= 引號 && 括號自動匹配 ======= " :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 " ESC + H Normal模式下開啓Devhelp查詢功能 function! DevHelpCurrentWord() let word = expand("<cword>") exe "!devhelp -s " . word . " &" endfunction nmap <esc>h :call DevHelpCurrentWord()<CR> " MiniBufExplorer 多個文件切換 可以使用鼠標雙擊相應文件名進行切換 let g:miniBufExplMapWindowNavVim=1 let g:miniBufExplMapWindowNavArrows=1 let g:miniBufExplMapCTabSwitchBufs=1 let g:miniBufExplModSelTarget=1 " :Tlist 調用TagList let Tlist_Show_One_File=1 " 只顯示當前文件的tags let Tlist_Exit_OnlyWindow=1 " 若是Taglist窗口是最後一個窗口則退出Vim let Tlist_Use_Right_Window=1 " 在右側窗口中顯示 let Tlist_File_Fold_Auto_Close=1 " 自動摺疊 " :LoadTemplate 根據文件類型自動加載模板 let g:template_path='~/.vim/template/' " snipMate Tab智能補全 let g:snips_author='Ruchee' " :AuthorInfoDetect 自動添加做者、時間等信息,本質是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 一步加載語法模板和做者、時間信息 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> set diffexpr=MyDiff() function MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let eq = '' if $VIMRUNTIME =~ ' ' if &sh =~ '\<cmd' let cmd = '""' . $VIMRUNTIME . '\diff"' let eq = '"' else let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' endif else let cmd = $VIMRUNTIME . '\diff' endif silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq endfunction