"關才兼容模式php
set nocompatiblecss
"模仿快捷鍵,如:ctrt+A 全選、Ctrl+C複製、 Ctrl+V 粘貼等html
source $VIMRUNTIME/vimrc_example.vimjava
source $VIMRUNTIME/mswin.vimpython
behave mswinvim
"gvim字體設置api
set guifont=新宋體:h14:cGB2312工具
"gvim 內部編碼字體
set encoding=utf-8ui
"當前編輯的文件編碼
set fileencoding=utf-8
"gvim打開支持編碼的文件
set fileencodings=ucs-bom,utf-8,gbk,cp936,gb2312,big5,euc-jp,euc-jp,euc-kr,latin1
"解決consle輸出亂碼
language messages zh_CN.UTF-8
"解決菜單亂碼
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"設置終端編碼爲gvim內部編碼encoding
let &termencoding=&encoding
" 防止特殊符號沒法正常顯示
set ambiwidth=double
"縮進尺寸爲4個空格
set sw=4
"tab 寬度爲4個字符
set ts=4
"編輯時將全部tab替換爲空格
set et
"按一次backspace就刪除4個空格了
set smarttab
"不生成備份文件,如~index.html
set nobackup
"開啓行號標記
set number
"配色方案爲desert
colo desert
"關才上側工具欄
set guioptions-=T
"關才右側滾動條
"set guioptions-=r
"開啓自動縮進
set autoindent
"代碼自動補全 (按快捷鍵Ctrl+X+O)
set autoindent
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt set omnifunc=javascrīptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
"代碼摺疊
"用空格鍵來開關摺疊(說明西方「"」後面的內容爲註釋,不會被VIM所識別)
set foldenable
set foldmethod=indent
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
"實現括號和引號自動補全
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {<CR>}<Esc>O
autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=CloseBracket()<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
function CloseBracket()
if match(getline(line('.') + 1), '\s*}') < 0
return "\<CR>}"
else
return "\<Esc>j0f}a"
endif
endf
function QuoteDelim(char)
let line = getline('.')
let col = col('.')
if line[col - 2] == "\\"
"Inserting a quoted quotation mark into the string
return a:char
elseif line[col - 1] == a:char
"Escaping out of the string
return "\<Right>"
else
"Starting a string
return a:char.a:char."\<Esc>i"
endif
endf