Skip to content

Instantly share code, notes, and snippets.

@llj098
Created November 12, 2010 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llj098/673796 to your computer and use it in GitHub Desktop.
Save llj098/673796 to your computer and use it in GitHub Desktop.
a small enhancement of vim
" File: pa.vim
" Author: llj098<llj098@gmail.com>
" Description: my plugin for myself
" Last Modified: 十一月 12, 2010
if exists('loaded_pa') || &cp || version < 700
finish
endif
let loaded_pa= 1
"imap <CR>
imap <C-CR> <ESC><Plug>pa
noremap <unique> <script> <Plug>pa <SID>jumpout
noremap <SID>jumpout :call <SID>jumpout()<CR>
"if you Press <CR> in a parenthesis, you can jump out of it, like eclipse
fun s:jumpout()
let line = getline('.')
let col = col('.')
let charleft = strpart(line,col)
let nextchar = strpart(line,col,1)
if(nextchar == '}')
call feedkeys("a\<CR>\<ESC>O\<Tab>",'t')
return
endif
let nextpos = match(charleft,"[\]\"\')]")
if nextpos < 0
call feedkeys("a")
return
endif
let cmd = "\<ESC>" .string(nextpos+1) . "la"
call feedkeys(cmd,'t')
endf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment