Vim InsertLeave事件不存在';使用CTRL-C而不是ESC时不会发生

Vim InsertLeave事件不存在';使用CTRL-C而不是ESC时不会发生,vim,Vim,我正在阅读Steve Losh的,并已添加到我的.vimrc中 " make status line red while in insert mode augroup hi_statusline autocmd! autocmd InsertEnter * hi StatusLine ctermbg=15 ctermfg=9 autocmd InsertLeave * hi StatusLine ctermbg=238 ctermfg=253 augroup END 然而,我注意

我正在阅读Steve Losh的,并已添加到我的.vimrc中

" make status line red while in insert mode
augroup hi_statusline
  autocmd!
  autocmd InsertEnter * hi StatusLine ctermbg=15  ctermfg=9
  autocmd InsertLeave * hi StatusLine ctermbg=238 ctermfg=253
augroup END
然而,我注意到一种奇怪的行为。有时我点击C-C退出插入模式,该模式工作正常,并且有文档记录。执行此操作时,InsertLeave事件不会触发。当我使用ESC时,它工作良好。这是vim已知的奇怪现象吗?是否有一种解决方法,通过连接到另一个表明InsertMode不再处于活动状态的事件

编辑| Meh,添加一个
inoremap
解决了这个问题,据我所知,它绝对没有副作用,因为C-C已经做了ESC所做的事情(返回到正常模式)。如果我错了,请纠正我。

:ino
:ino <C-C> <Esc>

^C通常是“立即让我离开这里”的键,如果您有autocmd,则不需要运行C-C即可成为您的朋友。

这在
:help i\u CTRL-C
下有说明:

CTRL-C  Quit insert mode, go back to Normal mode.  Do not check for
        abbreviations.  Does not trigger the |InsertLeave| autocommand
        event.
和往常一样,Bram达到了设计目标

:help design-documented

谢谢,在你发帖子之前,我也发现了这一点;)一旦5分钟的超时时间过去,我会接受你的回答,所以让我来做;)我之前在我的vimrc中已经将C-C映射到ESC,但由于我意识到它已经支持该行为,所以已经将其删除。。。显然,尽管有了这个微妙的特性.np,接受+upvote实际上让人觉得有点过头了。很高兴它对你有用:-)+1为“学习Vimscript的艰苦方式)参考,似乎非常有用!真正的意思是:中止所有运行的操作。这包括脚本,而自动命令是脚本。就这么简单。