Vim:一段时间后自动退出插入模式

标签 vim

我想让 Vim 离开 Insert一段时间(15 秒)后自动模式。这是我的内容
我的 .vimrc :

" set 'updatetime' to 15 seconds when in insert mode
au InsertEnter * let updaterestore = &updatetime | set updatetime=15000
au InsertLeave * let &updatetime = updaterestore

" automatically leave insert mode after 'updatetime' milliseconds of inaction
au CursorHoldI * stopinsert

我在 MacVim 中使用这个片段,但它不起作用。当我输入 Insert模式,而我什么都不做,
Vim 在 15 秒后离开插入模式。但是,如果我按 EnterBackspace ,或者如果我输入 Insert模式
使用 o/O ,然后 Vim 离开 Insert立即模式,然后,即使我输入 Insert模式使用 iVim 回到 Normal直接模式。

我在 Mac OS X 10.8.5 上使用 Homebrew 安装了 MacVim

任何想法为什么这不起作用?

编辑:这是我的带有所有标志的 MacVim 版本:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 29 2013 02:17:27)
MacOS X (unix) version
Included patches: 1-22
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_binary
+arabic          +find_in_path    -mouse_sysmouse  +tag_old_static
+autocmd         +float           +mouse_urxvt     -tag_any_white
+balloon_eval    +folding         +mouse_xterm     +tcl
+browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     +fullscreen      -mzscheme        +textobjects
+cindent         -gettext         +netbeans_intg   +title
+clientserver    -hangul_input    +odbeditor       +toolbar
+clipboard       +iconv           +path_extra      +transparency
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
+farsi           +mouse_netterm   +syntax          
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: cc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX -no-cpp-precomp  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/System/Library/Frameworks/Tcl.framework/Headers  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_DARWIN_C_SOURCE=1  
Linking: cc   -L.   -L.    -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lncurses -liconv -framework Cocoa   -fstack-protector -L/usr/local/lib  -L/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -framework Python  -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -framework Ruby   

最佳答案

正如@romainl 评论的那样,缩小此类问题的最快方法是二分法。基本上,您禁用(注释掉)vimrc 的一半以查看是否仍有问题,然后用另一半进行测试。如果只有其中一半有问题,则将其分成两半并重复,直到找到有问题的设置/插件/等。

为了理智起见,对于这样的问题,从测试最小设置(即仅包含问题描述中引用的行的 vimrc)开始,以确保它不是野鹅追逐也是一个好主意。

关于Vim:一段时间后自动退出插入模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19072830/

相关文章:

vim - VIM 中用 # 居中并填充多个空格

Vim 在插入模式下导航文本

sorting - vim 中可以对一组行进行排序吗?

Vim 病原体无法加载 - E117 : Unknown function: pathogen#infect

vim - 检测从普通 :map 调用的函数内的模式

无法将文件名分配给vim中的环境变量

使用 Vimgrep 搜索由多个 glob 指定的文件集

vim - UltiSnips 和 YouCompleteMe

regex - 如何让 vim 替换重复直到没有更多匹配项?

function - 两个括号内自动缩进 - Vim