Ingo Karkat wrote:

> On 30-Oct-2018 07:48 +0100, Christian Brabandt wrote:
> 
> > On Mo, 29 Okt 2018, Bok Woon Chua wrote:
> > 
> >> I have an autocmd that saves the current file on InsertLeave.
> >> Using C-c in insert mode doesn't trigger this save (as desired),
> >> but if I use it into an inoremap mapping like so
> >> 
> >> inoremap <C-a> <C-c>I
> >> 
> >> ,it triggers InsertLeave whenever I use C-a to jump to the start
> >> of the line and hence saves the file.
> >> 
> >> Is this intentional behavior? Is C-c supposed to avoid
> >> InsertLeave only if used interactively, rather than in a script?
> > 
> > I believe this is intentionally and expected. <c-c> does not work
> > as "abort" key if it comes from a mapping (or has been mapped).
> 
> Yes, that is the current behavior, but I agree with Bok Woon Chua that
> this is unexpected and inconsistent with how other mappings behave (i.e.
> they transparently forward the original behavior without changing it).
> The problem even occurs when mapping <C-c> onto itself (:inoremap <C-c>
> <C-c>).
> 
> I know that relying on <C-c> not triggering InsertLeave is bad form, and
> Vim's Todo list is very long, but especially in light of the recent poll
> about what plugin writers want, fixing such inconsistencies would be
> very welcome. In some situations, details like this can make or break a
> plugin implementation.

Unfortunately this behavior has been documented and users may rely on
the current behavior.

I was planning to add a more generic mode-change autocommand.  There is
a request for Visual mode enter/leave, for example.
Perhaps triggering whenever the return value of mode() would change is
the most generic solution.  But that needs some more investigation.

-- 
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui