Monday, September 22, 2014

Re: How to force Vim to reconcider abbreviations?

On Monday, September 22, 2014 11:11:37 AM UTC-5, gevisz wrote:
> On Mon, 22 Sep 2014 19:05:59 +0300
>
> Gevisz <gevisz@gmail.com> wrote:
>
>
>
> > So, it would be nice to have a short key mapping,
>
> > for example with <F4>, that would force Vim to
>
> > reconsider just typed abbreviation and expand it
>
> > even it was typed in the last session.
>
>
>
> A small correction:
>
>
>
> it would be nice to have a short key mapping,
>
> for example with <F4>, that would force Vim to
>
> reconsider the abbreviation just before the cursor
>
> and expand it even it was typed in the last session.

I was actually quite surprised to find that abbreviations don't work if you wait 'updatetime' milliseconds between starting and ending the abbreviation, triggering the CursorHoldI event. That could be due to specific events firing, I don't really know, but it is not documented anywhere I could find.

This mapping seems to do what you want, as a workaround:

inoremap <F4> <C-C>ciW<C-R>-<C-]>

<C-C> is used to end insert mode without triggering events or abbreviations, ciW then deletes the unexpanded abbreviation and enters insert mode, <C-R>- inserts that deleted text, and then <C-]> expands the abbreviation.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: