Christian wrote:
> On Do, 01 Nov 2018, 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>).
>
> Well, it's an inconsistency, that has been there for years and actually
> think one should not map C-C at all for exact that reason. Have you
> tried letting feedkeys() return `<c-c>`? I think that might actually
> work.
Well, let's see:
- The documentation mentions that CTRL-C does not trigger InsertLeave.
It doesn't mention that this is different for a mapping.
- The two ways to leave Insert mode could be useful sometimes,
especially part of a mapping that you don't want to trigger
InsertLeave (since the mapping will re-enter Insert mode soon after).
- I don't expect the change to cause trouble, since one would mostly use
Esc to leave insert mode, I don't see why someone would currently use
CTRL-C.
So let's make this change.
> BTW: There is another inconsistency, that is, that ESC that comes from a
> mapping execute the current commandline instead of aborting it.
That was done to make old Vi mappings work. Might even be for Posix
compatibility.
--
"Never be afraid to tell the world who you are."
-- Anonymous
/// 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.