tips : vim online
inoremap " ""<LEFT>
inoremap ' ''<LEFT>
inoremap [ []<LEFT>
inoremap ( ( )<LEFT><LEFT>
inoremap { {}<LEFT>
autocmd FileType html set matchpairs+=<:>
autocmd FileType html inoremap < <><LEFT>
autocmd FileType css inoremap : : ;<LEFT>
inoremap <silent> <ENTER> <C-R>=SmartEnter()<CR>
function! SmartEnter()
let line = getline( "." )
let brace = strpart( line, strlen( line ) - 2, 2 )
if ( brace == '{}' )
return "\<CR>\<CR>\<ESC>ka"
else
return "\<CR>"
endif
endf
" emacs like C-a C-e C-a
imap <C-a> <ESC>0i
imap <silent> <C-e> <ESC>:call InBrace()<CR>
function! InBrace()
let line = getline( "." )
let start = match( line, "(" )
let end = match( line, ")" )
if ( start > -1 && end > -1 )
let arg = strpart( line, start + 1, end - start -1 )
let res = match( arg, "[0-9a-zA-Z-_$]" )
if ( res < 0 )
exe "norm di)"
endif
echo res
endif
exe "norm $"
exe "star!"
endf