Tuesday, June 22, 2010

Re: Please help with iab problem

On Jun 22, 9:12 am, sc <tooth...@swbell.net> wrote:
> On Tuesday 22 June 2010 07:23:37 Jeremy wrote:
>
> > the abbreviation, but what is already after it.  For example,
> >  I will often (but not always) open and close a parenthesis,
> >  then move inside it to execute my abbreviation.  I believe
> >  Vim doesn't expand the abbreviation because there is a close
> >  parenthesis immediately after the abbreviation.  If I close
> >  the abbreviation with a <CR> instead of a space, then it
> >  works, but I get an extra <CR> which is not wanted
> >  either.  Any idea how to get around this?
>
> in
>
>     :h abbreviations
>
> there's a handy example i use in all my iabbrs:
>
> func Eatchar(pat)
>     let c = nr2char(getchar(0))
>     return (c =~ a:pat) ? '' : c
> endfunc
> iabbr <silent> if if ()<Left><C-R>=Eatchar('\s')<CR>
>
> you have to read down a way to see it
>
> as coded, it will eat a space and invoke the iabbr, but if you
> trigger with a <CR> it leaves it
>

I saw that in the documentation. I didn't implement it because I
don't always follow my abbreviation with a <CR> and when I do, I want
the <CR> removed. If I understand correctly, this is exactly opposite
from what you said. I think I will try using an imap instead of an
abbreviation.

Jeremy

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