thanks Ben Fritz, good article, teach me a lot, but I still has some
question.
function! ConditionalPairMap(open, close)
let line = getline('.')
let col = col('.')
if col < col('$') || stridx(line, a:close, col + 1) != -1
return a:open
else
return a:open . a:close . repeat("\<left>", len(a:close))
endif
endf
inoremap <expr> ( ConditionalPairMap('(', ')')
inoremap <expr> { ConditionalPairMap('{', '}')
inoremap <expr> [ ConditionalPairMap('[', ']')
inoremap <expr> /* ConditionalPairMap('/*', '*/')
inoremap <expr> /*<space> ConditionalPairMap('/*<space>', '*/<space>')
inoremap <expr> ' ConditionalPairMap("'", "'")
inoremap <expr> " ConditionalPairMap('\"', '\"')
autocmd FileType javascript inoremap , ,<SPACE>
autocmd FileType javascript inoremap : <SPACE>:<SPACE>
1. not works if insert ( [ { in the center of a line, only works at the end
of the line,
2. Can I use inoremap in function too? I want add this in function
inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ?
"\<Right>" : ")"
3, how can I get some API of strpart, get line, col, all of this internal
functions?
4, Where I can get the syntax of vim script, like string operation, ! #
symbols means
Thanks a lot
Ben Fritz <[email protected]>
>
>
> On Nov 11, 8:36 am, Jason <[email protected]> wrote:
> > I just need a very simple plugin, I want do it myself, when I press
> > {<enter> , it become
> >
> > below `I` means cursor
> >
> > {
> > I
> >
> > }
> >
> > if I press ({<enter> it goes to
> >
> > ({
> > I
> >
> > })
> >
> > |( => (|)
> > |{ => {|}
> >
> > I don't want to know every thing about plugin development, but I want
> > to know the most useful things about write a plugins.
>
> Have a look here, it will get you started and/or walk you through
> creating such mappings:
>
> http://vim.wikia.com/wiki/Automatically_append_closing_characters
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
--
Best regards,
Jason Green
桂林
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php