set fileencodings=utf-8,ucs-bom,big5
set encoding=big5
set hlsearch
set laststatus=2
set backspace=2
syntax on
set bg=dark
colorscheme desert
set noautoindent
"set autoindent
set ruler
set showmode
set nu
set tabstop=4
set sts=4 "softtabstop
set shiftwidth=4
set ai
set expandtab
set ignorecase
let loaded_matchparen = 1
set diffexpr=MyDiff()
set guifont=DejaVu_Sans_Mono:h11
"符號自動補齊
inoremap ( ()<left>
inoremap { {}<left>
inoremap [ []<left>
vnoremap <leader>" "zdi"<c-r>z"
vnoremap <leader>' "zdi'<c-r>z'
vnoremap <leader>( "zdi(<c-r>z)
vnoremap <leader>[ "zdi[<c-r>z]
vnoremap <leader>{ "zdi{<c-r>z}
inoremap <expr> <bs> <SID>delpair()
inoremap <expr> ) <SID>escapepair(')')
inoremap <expr> } <SID>escapepair('}')
inoremap <expr> ] <SID>escapepair(']')
inoremap <expr> " <SID>pairquotes('"')
inoremap <expr> ' <SID>pairquotes("'")
function! s:delpair()
let l:lst = ['""',"''",'{}','[]','()']
let l:col = col('.')
let l:line = getline('.')
let l:chr = l:line[l:col-2 : l:col-1]
if index(l:lst, l:chr) > -1
return "\<bs>\<del>"
else
let l:chr = l:line[l:col-3:l:col-2]
if (index(l:lst, l:chr)) > - 1
return "\<bs>\<bs>"
endif
return "\<bs>"
endf
function! s:escapepair(right)
let l:col = col('.')
let l:chr = getline('.')[l:col-1]
if a:right == l:chr
return "\<right>"
else
return a:right
endf
function! s:pairquotes(pair)
let l:col = col('.')
let l:line = getline('.')
let l:chr = l:line[l:col-1]
if a:pair == l:chr
return "\<right>"
else
return a:pair.a:pair."\<left>"
endf
"PHP條件式自動補齊
function! InsertPhp()
let word = getline('.')
if word =~ '\s*\(if\|elseif\|while\|switch\|for\|foreach\)
return " () {\<NL>}\<UP>\<END>\<LEFT>\<left>\<left>"
endif
if word =~ '\s*\class
return " \<NL>{\<NL>}\<UP>\<UP>\<END>"
endif
if word =~ '\s*\function
return " \<NL>{\<NL>}\<UP>\<UP>\<END>()\<LEFT>\<LEFT>"
endif
return "\<SPACE>"
endfunction
inoremap <expr> <SPACE> InsertPhp()
"HTML標籤自動補齊
function! InsertHtmlTag()
let pat = '\c<\w\+\s*\(\s\+\w\+\s*=\s*[''#$;,()."a-z0-9]\+\)*\s*>'
normal! a>
let save_cursor = getpos('.')
let result = matchstr(getline(save_cursor[1]), pat)
"if (search(pat, 'b', save_cursor[1]) && searchpair('<','','>', 'bn',0,getline('.')) > 0)
if (search(pat, 'b', save_cursor[1]))
normal! lyiwf>
normal! a</
normal! p
normal! a>
endif
:call cursor(save_cursor[1], save_cursor[2], save_cursor[3])
endfunction
inoremap > <ESC>:call InsertHtmlTag()<CR>a
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
顯示結果