Thursday, September 25, 2014

Re: How to force Vim to reconcider abbreviations?

On Thursday, September 25, 2014 12:10:09 AM UTC-5, Tony Mechelynck wrote:
> On 22/09/14 19:37, Ben Fritz wrote:
>
> > 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.
>
>
>
> What is documented is that mappings expire after 'timoutlen'
>
> milliseconds. Abbreviations are not explicitly mentioned there, but I
>
> imagine that they might share part of the mapping code.
>
>
>
> - Try setting 'timeoutlen' and 'updatetime' to very different valuies so
>
> you can easily tell which of them is relevant;
>
> - If 'updatetime' does trigger abbreviations even when very different
>
> from 'timeoulen', does it make a difference if you remove any CursoHoldI
>
> autocommands that you might have?
>
>

Oh, it's definitely 'updatetime' and CursorHoldI. In my case abbreviations would expand if I waited a few seconds, but if I waited longer the cursor would briefly pause in its flashing as my autocmds processed, and after that abbreviations would not expand. I checked my autocmds and found the culprit.

In my case the behavior is caused by this autocmd, which I did not remember having, and I can probably understand why it would impact abbreviations:

if exists("##CursorHoldI")
autocmd CursorHoldI * call feedkeys("\<C-G>u", "nt")
endif

The autocmd breaks the undo sequence if pausing for a long time in insert mode, since if I pause a long time in insert mode I'm probably making multiple changes. I imagine breaking the undo sequence also breaks the insert so that it no longer looks like I typed the whole abbreviation this insert session.

I'm sure there may be other autocmds or plugins which could cause similar problems; all they must do is break the undo sequence somehow.

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

Post a Comment