Created
November 12, 2010 06:12
-
-
Save llj098/673796 to your computer and use it in GitHub Desktop.
a small enhancement of vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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