您好,登錄后才能下訂單哦!
" 永遠(yuǎn)的冰點(diǎn)的VIM配置件 " 2011/12/17 " imbingdian@gmail.com " http://wlog.cn if v:version < 700 echoerr 'This _vimrc requires Vim 7 or later.' quit endif " 設(shè)置菜單語(yǔ)言 set langmenu=zh_cn " ========= " 功能函數(shù) " ========= " 獲取當(dāng)前目錄 func GetPWD() return substitute(getcwd(), "", "", "g") endf " ========= " 環(huán)境配置 " ========= " 保留歷史記錄 set history=600 " 命令行于狀態(tài)行 set ch=1 set stl=\ [File]\ %F%m%r%h%y[%{&fileformat},%{&fileencoding}]\ %w\ \ [PWD]\ %r%{GetPWD()}%h\ %=\ [Line]\ %l,%c\ %=\ %P set ls=2 "始終顯示狀態(tài)行 " 狀態(tài)欄顯示目前所執(zhí)行的指令 set showcmd " 控制臺(tái)響鈴(關(guān)閉遇到錯(cuò)誤時(shí)的聲音提示) :set noerrorbells :set novisualbell :set t_vb= "close visual bell " 行控制 set linebreak "英文單詞在換行時(shí)不被截?cái)?nbsp; set nocompatible "設(shè)置不兼容VI set textwidth=80 "設(shè)置每行80個(gè)字符自動(dòng)換行,加上換行符 set wrap "設(shè)置自動(dòng)折行 " 縮進(jìn) set autoindent "設(shè)置自動(dòng)縮進(jìn) set smartindent "設(shè)置智能縮進(jìn) " 行號(hào)和標(biāo)尺 set number "行號(hào) set ruler "在右下角顯示光標(biāo)位置的狀態(tài)行 set rulerformat=%15(%c%V\ %p%%%) " 標(biāo)簽頁(yè) set tabpagemax=20 "最多20個(gè)標(biāo)簽 set showtabline=2 "總是顯示標(biāo)簽欄 " tab轉(zhuǎn)化為4個(gè)字符 set tabstop=4 set expandtab set smarttab set shiftwidth=4 set softtabstop=4 "設(shè)置行高 set linespace=4 " 插入模式下使用 <BS>、<Del> <C-W> <C-U> set backspace=indent,eol,start " 自動(dòng)重新讀入 set autoread " 自動(dòng)改變當(dāng)前目錄 if has('netbeans_intg') set autochdir endif "搜索 set ignorecase "在查找時(shí)忽略大小寫(xiě) set incsearch "關(guān)閉顯示查找匹配過(guò)程 set hlsearch "高亮顯示搜索的內(nèi)容 " 顯示匹配的括號(hào) " set showmatch " 匹配配對(duì)的字符 func! MatchingQuotes() inoremap ( ()<left> inoremap [ []<left> inoremap { {}<left> inoremap " ""<left> inoremap ' ''<left> endf " 在所有模式下都允許使用鼠標(biāo),還可以是n,v,i,c等 set mouse=a " 恢復(fù)上次文件打開(kāi)位置 set viminfo='10,\"100,:20,%,n~/.viminfo au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif " Diff 模式的時(shí)候鼠標(biāo)同步滾動(dòng) for Vim7.3 if has('cursorbind') set cursorbind end " ===================== " 多語(yǔ)言環(huán)境 " 默認(rèn)為 UTF-8 編碼 " ===================== if has("multi_byte") set encoding=utf-8 " English messages only "language messages zh_CN.utf-8 if has('win32') language english let &termencoding=&encoding endif set fencs=utf-8,gbk,chinese,latin1 set formatoptions+=mM set nobomb " 不使用 Unicode 簽名 if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)' set ambiwidth=double endif else echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte" endif filetype plugin indent on "打開(kāi)文件類型檢測(cè) " :help mbyte-IME if has('multi_byte_ime') highlight Cursor guibg=#F0E68C guifg=#708090 highlight CursorIM guibg=Purple guifg=NONE endif " ===================== " AutoCmd 自動(dòng)運(yùn)行 " ===================== if has("autocmd") " 括號(hào)自動(dòng)補(bǔ)全 func! AutoClose() :inoremap ( ()<ESC>i :inoremap " ""<ESC>i :inoremap ' ''<ESC>i :inoremap { {}<ESC>i :inoremap [ []<ESC>i :inoremap ) <c-r>=ClosePair(')')<CR> :inoremap } <c-r>=ClosePair('}')<CR> :inoremap ] <c-r>=ClosePair(']')<CR> endf func! ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endf augroup vimrcEx "記住上次文件位置 au! autocmd FileType text setlocal textwidth=80 autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif augroup END " Auto close quotation marks for PHP, Javascript, etc, file au FileType php,javascript exe AutoClose() au FileType php,javascript exe MatchingQuotes() " Auto Check Syntax " au BufWritePost,FileWritePost *.js,*.php call CheckSyntax(1) " JavaScript 語(yǔ)法高亮 au FileType html,javascript let g:javascript_enable_domhtmlcss = 1 au BufRead,BufNewFile *.js setf jquery " 打開(kāi)javascript對(duì)dom、html和css的支持 let javascript_enable_domhtmlcss=1 " 給各語(yǔ)言文件添加 Dict if has('win32') let s:dict_dir = $VIM.'\vimfiles\dict\' else let s:dict_dir = $HOME."/.vim/dict/" endif let s:dict_dir = "setlocal dict+=".s:dict_dir au FileType php exec s:dict_dir."php_funclist.dict" au FileType css exec s:dict_dir."css.dict" au FileType javascript exec s:dict_dir."javascript.dict" " 增加 ActionScript 語(yǔ)法支持 au BufNewFile,BufRead,BufEnter,WinEnter,FileType *.as setf actionscript " CSS3 語(yǔ)法支持 au BufRead,BufNewFile *.css set ft=css syntax=css3 " 增加 Objective-C 語(yǔ)法支持 au BufNewFile,BufRead,BufEnter,WinEnter,FileType *.m,*.h setf objc " 將指定文件的換行符轉(zhuǎn)換成 UNIX 格式 au FileType php,javascript,html,css,python,vim,vimwiki set ff=unix " 保存編輯狀態(tài) au BufWinLeave * if expand('%') != '' && &buftype == '' | mkview | endif au BufRead * if expand('%') != '' && &buftype == '' | silent loadview | syntax on | endif endif " ========= " 圖形界面 " ========= if has('gui_running') " 只顯示菜單 set guioptions=mcr " 高亮光標(biāo)所在的行 set cursorline " 編輯器配色 "colorscheme zenburn "colorscheme dusk "colorscheme breeze "colorscheme molokai set background=light "for solarized colorscheme solarized if has("win32") " Windows 兼容配置 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim " f11 最大化 /vimfiles/extra/fullscreen/gvimfullscreen.dll移動(dòng)到安裝目錄 "nmap <f11> :call libcallnr('gvimfullscreen.dll', 'ToggleFullScreen', 0)<cr> "nmap <Leader><Leader> :call libcallnr('gvimfullscreen.dll', 'ToggleFullScreen', 0)<cr> " 自動(dòng)最大化窗口 au GUIEnter * simalt ~x " 給 Win32 下的 gVim 窗口設(shè)置透明度 http://www.vim.org/scripts/script.php?script_id=687 "/vimfiles/extra/vimtweak/vimtweak.dll移動(dòng)到安裝目錄 " au GUIEnter * call libcallnr("vimtweak.dll", "SetAlpha", 250) " 字體配置 "http://support.microsoft.com/kb/306527/zh-cn "set guifont=Droid\ Sans\ Mono:h20.5:cANSI "set guifontwide=YouYuan:h20.5:cGB2312 "cygwin路徑 "set shell=d:\cygwin\bin\mintty.exe\ - endif " Under Mac if has("gui_macvim") "開(kāi)啟抗鋸齒渲染 set anti " MacVim 下的字體配置 "set guifont=Courier_New:h24 "set guifontwide=YouYuan:h24 "set guifontwide=Microsoft\ Yahei\ Mono:h24 "set guifontwide=YouYuan:h23 "set guifontwide=YouYuan:h24 "set guifont=Droid\ Sans\ Mono:h24 "set guifontwide=Yahei_Mono:h24 set guifont=Monaco:h24 set guifontwide=YouYuan:h24 " 半透明和窗口大小 set transparency=2 set lines=300 columns=120 " 使用 MacVim 原生的全屏幕功能 let s:lines=&lines let s:columns=&columns func! FullScreenEnter() set lines=999 columns=999 set fu endf func! FullScreenLeave() let &lines=s:lines let &columns=s:columns set nofu endf func! FullScreenToggle() if &fullscreen call FullScreenLeave() else call FullScreenEnter() endif endf set guioptions+=e " Mac 下,按 \\ 切換全屏 nmap <f11> :call FullScreenToggle()<cr> nmap <Leader><Leader> :call FullScreenToggle()<cr> " I like TCSH :^) set shell=/bin/tcsh " Set input method off set imdisable " Set QuickTemplatePath let g:QuickTemplatePath = $HOME.'/.vim/templates/' " 如果為空文件,則自動(dòng)設(shè)置當(dāng)前目錄為桌面 lcd ~/Desktop/ endif " Under Linux/Unix etc. if has("unix") && !has('gui_macvim') set guifont=Courier\ 10\ Pitch\ 11 endif endif " JSLint.vim if has("win32") let g:jslint_command = $VIMFILES . '/extra/jsl/win/jsl.exe' else let g:jslint_command = $VIMFILES . '/extra/jsl/mac/jsl' endif let g:jslint_highlight_color = '#996600' "let g:jslint_command_options = '-conf ' . $VIMFILES . '/extra/jsl/jsl.conf -nofilelisting -nocontext -nosummary -nologo -process' "let g:jslint_command_options = '-nofilelisting -nocontext -nosummary -nologo -process' " ========= " 插件 " ========= " Calendar " http://www.vim.org/scripts/script.php?script_id=52 if has("gui_macvim") let g:calendar_diary=$HOME.'/.vim/diary/' endif map cal :Calendar<cr> " NERDTree " http://www.vim.org/scripts/script.php?script_id=1658 let NERDTreeWinSize=22 map ntree :NERDTree <cr> map nk :NERDTreeClose <cr> map <leader>n :NERDTreeToggle<cr> " 新建 XHTML 、PHP、Javascript 文件的快捷鍵 nmap <C-c><C-h> :NewQuickTemplateTab xhtml<cr> nmap <C-c><C-g> :NewQuickTemplateTab html<cr> nmap <C-c><C-p> :NewQuickTemplateTab php<cr> nmap <C-c><C-j> :NewQuickTemplateTab javascript<cr> nmap <C-c><C-c> :NewQuickTemplateTab css<cr> " jsbeauty "http://www.vim.org/scripts/script.php?script_id=2727 " \ff " ========= " 快捷鍵 " ========= " 標(biāo)簽相關(guān)的快捷鍵 Ctrl map tn :tabnext<cr> map tp :tabprevious<cr> map tc :tabclose<cr> map <C-n> :tabnew<cr> map <C-Tab> :tabnext<cr> "最近打開(kāi)的文件 nmap <Leader>mr :MRU<cr> "字體大小 "http://www.vim.org/scripts/script.php?script_id=2809 "<Leader>== Begin "font size" mode "<Leader>++ Increment font size "<Leader>-- Decrement font size "<Leader>00 Revert to default font size " 在文件名上按gf時(shí),在新的tab中打開(kāi) map gf :tabnew <cfile><cr> " 返回當(dāng)前時(shí)間 func! GetTimeInfo() "return strftime('%Y-%m-%d %H:%M:%S') return strftime('%Y-%m-%d') endfunction " 插入模式按 Ctrl + D(ate) 插入當(dāng)前時(shí)間 imap <C-d> <C-r>=GetTimeInfo()<cr> "F12啟動(dòng)firefox if has("win32") map <F12> :silent! !"C:\Program Files\Mozilla Firefox\firefox.exe" % <CR> endif "zen-coding,(c+y+,) let g:user_zen_expandabbr_key = '<c-e>' let g:use_zen_complete_tag = 1 " 保證語(yǔ)法高亮 syntax on " ========= " 幫助 " ========= " :shell 進(jìn)入終端 " jsbeauty \ff set helplang=cn " ========= " js、css壓縮 " ========= "autocmd BufWriteCmd *.js :call CompileJS() "保存時(shí)自動(dòng)壓縮js "默認(rèn) :Gcc 命令壓縮js "autocmd BufWriteCmd *.js :call CompressCss() "保存時(shí)自動(dòng)壓縮css "默認(rèn) :Ycc 命令壓縮css
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。