Tuesday, November 30, 2010

Re: [HELP]inoremap problem

On Tue, 30 Nov 2010, Zhanglistar wrote:

> :inoremap ( ()<ESC>i
> :inoremap ) <c-r>=ClosePair(')')<CR>
> :inoremap { {}<ESC>i
> :inoremap } <c-r>=ClosePair('}')<CR>
> :inoremap [ []<ESC>i
> :inoremap ] <c-r>=ClosePair(']')<CR>
> :inoremap < <><ESC>i
> :inoremap > <c-r>=ClosePair('>')<CR>
>
> function ClosePair(char)
> if getline('.')[col('.') - 1] == a:char
> return "\<Right>"
> else
> return a:char
> endif
> endf
>
> I have added the lines above to my vimrc, but vim does't automatically
> complete bracket, What's wrong with my vim?

I assume you have trouble only with '<'? You need to change:

:inoremap < <><ESC>i

to:

:inoremap < <lt>><ESC>i

See #3 under: :help <>

With that change, all of your mappings work fine for me.

--
Best,
Ben

--
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

No comments:

Post a Comment