Thursday, June 20, 2013

Call a function in insertmode without triggering InsertLeave

I want to have some stuff executed when I press Escape, so I set an autocommand InsertLeave which works fine. But I don't want to execute it when Vim goes to normal mode during a mapping. So I changed

:imap key <Esc>:call function()<CR>

to

:imap key <C-c>:call function()<CR>

because the help says that <C-c> doesn't trigger the InsertLeave command. This is true when I type <C-c> manually, but not when I use it in a mapping. The autocommand is still executed. Is it a bug or a feature?

Dealing with <C-R>= as proposed here:
https://groups.google.com/d/msg/vim_use/-RaWsBLe1aE/OOdqYKsyG7YJ
doesn't work for me because I want to move the cursor in my function.
So, any idea?




--
--
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/groups/opt_out.

No comments:

Post a Comment