您好,登錄后才能下訂單哦!
" 永遠的冰點的VIM配置件 " 2011/12/17 " imbingdian@gmail.com " http://wlog.cn if v:version < 700 echoerr 'This _vimrc requires Vim 7 or later.' quit endif " 設置菜單語言 set langmenu=zh_cn " ========= " 功能函數 " ========= " 獲取當前目錄 func GetPWD() return substitute(getcwd(), "", "", "g") endf " ========= " 環境配置 " ========= " 保留歷史記錄 set history=600 " 命令行于狀態行 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 "始終顯示狀態行 " 狀態欄顯示目前所執行的指令 set showcmd " 控制臺響鈴(關閉遇到錯誤時的聲音提示) :set noerrorbells :set novisualbell :set t_vb= "close visual bell " 行控制 set linebreak "英文單詞在換行時不被截斷 set nocompatible "設置不兼容VI set textwidth=80 "設置每行80個字符自動換行,加上換行符 set wrap "設置自動折行 " 縮進 set autoindent "設置自動縮進 set smartindent "設置智能縮進 " 行號和標尺 set number "行號 set ruler "在右下角顯示光標位置的狀態行 set rulerformat=%15(%c%V\ %p%%%) " 標簽頁 set tabpagemax=20 "最多20個標簽 set showtabline=2 "總是顯示標簽欄 " tab轉化為4個字符 set tabstop=4 set expandtab set smarttab set shiftwidth=4 set softtabstop=4 "設置行高 set linespace=4 " 插入模式下使用 <BS>、<Del> <C-W> <C-U> set backspace=indent,eol,start " 自動重新讀入 set autoread " 自動改變當前目錄 if has('netbeans_intg') set autochdir endif "搜索 set ignorecase "在查找時忽略大小寫 set incsearch "關閉顯示查找匹配過程 set hlsearch "高亮顯示搜索的內容 " 顯示匹配的括號 " set showmatch " 匹配配對的字符 func! MatchingQuotes() inoremap ( ()<left> inoremap [ []<left> inoremap { {}<left> inoremap " ""<left> inoremap ' ''<left> endf " 在所有模式下都允許使用鼠標,還可以是n,v,i,c等 set mouse=a " 恢復上次文件打開位置 set viminfo='10,\"100,:20,%,n~/.viminfo au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif " Diff 模式的時候鼠標同步滾動 for Vim7.3 if has('cursorbind') set cursorbind end " ===================== " 多語言環境 " 默認為 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 "打開文件類型檢測 " :help mbyte-IME if has('multi_byte_ime') highlight Cursor guibg=#F0E68C guifg=#708090 highlight CursorIM guibg=Purple guifg=NONE endif " ===================== " AutoCmd 自動運行 " ===================== if has("autocmd") " 括號自動補全 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 語法高亮 au FileType html,javascript let g:javascript_enable_domhtmlcss = 1 au BufRead,BufNewFile *.js setf jquery " 打開javascript對dom、html和css的支持 let javascript_enable_domhtmlcss=1 " 給各語言文件添加 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 語法支持 au BufNewFile,BufRead,BufEnter,WinEnter,FileType *.as setf actionscript " CSS3 語法支持 au BufRead,BufNewFile *.css set ft=css syntax=css3 " 增加 Objective-C 語法支持 au BufNewFile,BufRead,BufEnter,WinEnter,FileType *.m,*.h setf objc " 將指定文件的換行符轉換成 UNIX 格式 au FileType php,javascript,html,css,python,vim,vimwiki set ff=unix " 保存編輯狀態 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 " 高亮光標所在的行 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移動到安裝目錄 "nmap <f11> :call libcallnr('gvimfullscreen.dll', 'ToggleFullScreen', 0)<cr> "nmap <Leader><Leader> :call libcallnr('gvimfullscreen.dll', 'ToggleFullScreen', 0)<cr> " 自動最大化窗口 au GUIEnter * simalt ~x " 給 Win32 下的 gVim 窗口設置透明度 http://www.vim.org/scripts/script.php?script_id=687 "/vimfiles/extra/vimtweak/vimtweak.dll移動到安裝目錄 " 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") "開啟抗鋸齒渲染 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/' " 如果為空文件,則自動設置當前目錄為桌面 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 " ========= " 快捷鍵 " ========= " 標簽相關的快捷鍵 Ctrl map tn :tabnext<cr> map tp :tabprevious<cr> map tc :tabclose<cr> map <C-n> :tabnew<cr> map <C-Tab> :tabnext<cr> "最近打開的文件 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時,在新的tab中打開 map gf :tabnew <cfile><cr> " 返回當前時間 func! GetTimeInfo() "return strftime('%Y-%m-%d %H:%M:%S') return strftime('%Y-%m-%d') endfunction " 插入模式按 Ctrl + D(ate) 插入當前時間 imap <C-d> <C-r>=GetTimeInfo()<cr> "F12啟動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 " 保證語法高亮 syntax on " ========= " 幫助 " ========= " :shell 進入終端 " jsbeauty \ff set helplang=cn " ========= " js、css壓縮 " ========= "autocmd BufWriteCmd *.js :call CompileJS() "保存時自動壓縮js "默認 :Gcc 命令壓縮js "autocmd BufWriteCmd *.js :call CompressCss() "保存時自動壓縮css "默認 :Ycc 命令壓縮css
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。