Vim: Automatically leave insert mode after some time - vim

I want to make Vim leave Insert mode automagically after some time (15 seconds). Here is what I've got in
my .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
I am using this snippet in MacVim, and it doesn't work. When I enter Insert mode, and I don't do anything,
Vim leaves insert mode after 15 seconds. However, if I press Enter or Backspace, or if I enter Insert mode
using o/O, then Vim leaves Insert mode straight away, and at that point, even if I enter Insert mode using i
Vim goes back to Normal mode straight away.
I installed MacVim using Homebrew on Mac OS X 10.8.5
Any ideas why this is not working please?
Edit: Here is my MacVim version with all the flags:
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

As #romainl commented, the fastest way to narrow down a problem like this is bisection. Basically, you disable (comment out) half of your vimrc to see if you still have the problem, then test it with the other half. If only one of those halves has the problem, you split it in half and repeat until you find the offending setting/plugin/etc.
For sanity's sake, with an issue like this it's also a good idea to start by testing a minimal setup (i.e. a vimrc with just the lines quoted in the problem description) to make sure it's not a wild goose chase.

Related

Exit code -11 after installation of Vim auto completion plugin YouCompleteMe with MacVim (Vim version 8.1)

I'd like to install the auto completion plugin YouCompleteMe for Vim.
I followed the instructions of the installation guide at https://github.com/Valloric/YouCompleteMe/blob/master/README.md#full-installation-guide
I chose the simpler option without semantic completion support for C-family languages.
Executing
vim --version
returns
VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 19 2019 12:07:03)
macOS version
Included patches: 1-950
Compiled by Homebrew
Huge version with MacVim GUI. Features included (+) or not (-):
+acl -farsi +mouse_sgr -tag_any_white
+arabic +file_in_path -mouse_sysmouse -tcl
+autocmd +find_in_path +mouse_urxvt +termguicolors
+autochdir +float +mouse_xterm +terminal
-autoservername +folding +multi_byte +terminfo
+balloon_eval -footer +multi_lang +termresponse
+balloon_eval_term +fork() -mzscheme +textobjects
+browse +fullscreen +netbeans_intg +textprop
++builtin_terms -gettext +num64 +timers
+byte_offset -hangul_input +odbeditor +title
+channel +iconv +packages +toolbar
+cindent +insert_expand +path_extra +transparency
+clientserver +job +perl +user_commands
+clipboard +jumplist +persistent_undo +vartabs
+cmdline_compl +keymap +postscript +vertsplit
+cmdline_hist +lambda +printer +virtualedit
+cmdline_info +langmap +profile +visual
+comments +libcall -python +visualextra
+conceal +linebreak +python3 +viminfo
+cryptv +lispindent +quickfix +vreplace
+cscope +listcmds +reltime +wildignore
+cursorbind +localmap +rightleft +wildmenu
+cursorshape +lua +ruby +windows
+dialog_con_gui +menu +scrollbind +writebackup
+diff +mksession +signs -X11
+digraphs +modify_fname +smartindent -xfontset
+dnd +mouse +startuptime +xim
-ebcdic +mouseshape +statusline -xpm
+emacs_tags +mouse_dec -sun_workshop -xsmp
+eval -mouse_gpm +syntax -xterm_clipboard
+ex_extra -mouse_jsbterm +tag_binary -xterm_save
+extra_search +mouse_netterm +tag_old_static
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"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -DMACOS_X -DMACOS_X_DARWIN -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -L. -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon -lm -lncurses -liconv -framework AppKit -L/usr/local/opt/lua/lib -llua5.3 -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation -framework Ruby
I added the line
Plugin 'Valloric/YouCompleteMe'
to my .vimrc, afterwards the Vim command
:PluginInstall
executes without errors.
If I then start Vim the following error message is displayed:
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code -11. Type ':YcmToggleLogs ycmd_62275_stderr_menu0zqa.log' to check the logs.
The here mentioned log file is empty. Does anyone know what's the problem here?
I know there are a lot of other questions on StackOverflow and Github regarding very similar problems. But since I've spent the last 3 hours going through these and trying to get the plugin to work without success, I'd be happy if this won't be marked as duplicate and am very grateful for every response.
https://valloric.github.io/YouCompleteMe/#faq
YCM does not work with my Anaconda Python setup
Anaconda is often incompatible with the pre-built libclang used by YCM and therefore is not supported. The recommended way to solve this is to run /path/to/real/python install.py (for example /usr/bin/python install.py).
If you want completion in Anaconda projects, point the interpreter_path option in your .ycm_extra_conf.py file to the path of your Anaconda Python e.g.
def Settings(**kwargs):
return {
'interpreter_path': '/path/to/anaconda/python'
}
See the Python Semantic Completion section for more details.

vim puts extra space for every accented character

Whenever I type an accented character in vim, like for example: é it places an extra space like so é<space>.
Small gif animation that illustrates the problem: Link here. Notice that in the screen recording I am at no point pressing the space bar and yet they appear.
It's the exact same problem as described in this SO question and in Super user question too, but the solution proposed for both - set encoding=utf-8 - is not working for me. I've placed that in both the .vimrc and in a running session and none worked.
In MacVim, which set encoding? also outputs encoding=utf-8, this issue doesn't happen.
I installed vim with brew, here's the info command of it:
vim: stable 7.4.488, HEAD
http://www.vim.org/
Conflicts with: ex-vi
/usr/local/Cellar/vim/7.4.488 (1600 files, 26M) *
Built from source with: --override-system-vi
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/vim.rb
==> Dependencies
Optional: lua ✔, luajit ✔
==> Options
--disable-nls
Build vim without National Language Support (translated messages, keymaps)
--override-system-vi
Override system vi
--with-client-server
Enable client/server mode
--with-lua
Build vim with lua support
--with-luajit
Build with luajit support
--with-mzscheme
Build vim with mzscheme support
--with-python3
Build vim with python3 instead of python[2] support
--with-tcl
Build vim with tcl support
--without-perl
Build vim without perl support
--without-python
Build vim without python support
--without-ruby
Build vim without ruby support
--HEAD
Install HEAD version
And :version info here:
:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 5 2015 21:44:59)
MacOS X (unix) version
Included patches: 1-258
Compiled by Homebrew
Huge version with MacVim GUI. Features included (+) or not (-):
+acl +cmdline_info +emacs_tags -gettext +lua +mouse_urxvt +profile +statusline +transparency -X11
+arabic +comments +eval -hangul_input +menu +mouse_xterm +python -sun_workshop +user_commands -xfontset
+autocmd +conceal +ex_extra +iconv +mksession +multi_byte -python3 +syntax +vertsplit +xim
+balloon_eval +cryptv +extra_search +insert_expand +modify_fname +multi_lang +quickfix +tag_binary +virtualedit -xsmp
+browse +cscope +farsi +jumplist +mouse -mzscheme +reltime +tag_old_static +visual -xterm_clipboard
++builtin_terms +cursorbind +file_in_path +keymap +mouseshape +netbeans_intg +rightleft -tag_any_white +visualextra -xterm_save
+byte_offset +cursorshape +find_in_path +langmap +mouse_dec +odbeditor +ruby +tcl +viminfo -xpm
+cindent +dialog_con_gui +float +libcall -mouse_gpm +path_extra +scrollbind +terminfo +vreplace
+clientserver +diff +folding +linebreak -mouse_jsbterm +perl +signs +termresponse +wildignore
+clipboard +digraphs -footer +lispindent +mouse_netterm +persistent_undo +smartindent +textobjects +wildmenu
+cmdline_compl +dnd +fork() +listcmds +mouse_sgr +postscript -sniff +title +windows
+cmdline_hist -ebcdic +fullscreen +localmap -mouse_sysmouse +printer +startuptime +toolbar +writebackup
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: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -DMACOS_X_UNIX -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Ve
rsions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -I/usr/local/inclu
de -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -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: clang -L. -L/usr/local/lib -L. -L/usr/local/lib -L/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -framework Core
Foundation -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon -lm -lncurses -liconv -framework Cocoa -pagezero_size 10000 -image_base 100000000 -L/usr/local/lib -llu
ajit-5.1 -fstack-protector -L/usr/local/lib -L/System/Library/Perl/5.16/darwin-thread-multi-2level/CORE -lperl -framework Python -F/System/Library/Frameworks -framework Tcl -frame
work CoreFoundation -framework Ruby
And my locale:
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
Any ideas? Thanks.
None of the suggestions of the comments worked for me, so I kept on digging on the issue myself. In the end it was just a matter of unchecking an iTerm setting.

Why is a curly brace (ExpressionEngine tag) causing lines to wrap in HTML?

I've found that ExpressionEngine tags are wrapping in HTML filetypes, dependent upon three factors:
formatoptions includes c
filetype plugin on is set
An ExpressionEngine tag is indented (tabs or spaces) and goes past textwidth
It seems Vim is considering a line beginning with [whitespace]{ to be a comment in HTML, which as far as I know it shouldn't. Interestingly, even though Vim thinks of this line as a comment, with fo+=o set, hitting o doesn't cause the next line to be prepended with anything like a curly brace.
To reproduce:
1) Run vim with no plugins or settings using vim -u NONE -N
2) Run the following commands:
filetype plugin on
set tw=80
set tabstop=2
set ft=html
set fo-=t
At this point the filetype will be html and the formatoptions will be cq
3) Insert the following HTML/EE code:
<div>
<p>
{exp:structure:breadcrumb here_as_title="yes" inc_here="yes" separator="›"}
4) The text will wrap when you type the q of ›
Here is my output of :version:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 22 2012 15:36:46)
Compiled by root#apple.com
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments -conceal
+cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path +find_in_path +float
+folding -footer +fork() -gettext -hangul_input +iconv +insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu
+mksession +modify_fname +mouse -mouseshape -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme
+netbeans_intg -osfiletype +path_extra -perl +persistent_undo +postscript +printer -profile +python/dyn -python3 +quickfix +reltime -rightleft +ruby/dyn +scrollbind
+signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe
Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses
This is really baffling to me so if you need any more information to help me diagnose this, please let me know. Thank you.

Vim insert mode not allowing editing of existing lines in file, only newly added lines

It used to be that when I went into insert mode on an existing file, I could hit "delete" and that would work. Now I can still delete and modify things that I newly add to a file, but if there is existing stuff there once I open a file, I do not have the ability to delete that. I can only delete and modify new stuff. Out of insert mode however I still have the ability to delete things with the regular dd type commands. My .vimrc is pretty simple, and my only addon is SuperTab.
Here is my .vimrc if that helps:
set tags=./tags,~/kent/src/tags,~/kent/src/lib/tags,~/kent/src/inc/tags,~/kent/src/hg/lib/tags,~/kent/src/hg/inc/tags,~/kent/src/jkOwnLib/tags
syntax on
filetype indent plugin on
set modeline
au FileType python setlocal tabstop=8 expandtab shiftwidth=4 softtabstop=4
set background=dark
set wildmode=longest,list,full
set wildmenu
And here is the output from vim --version:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 8 2012 10:41:54)
Included patches: 1-434
Compiled by John St. John
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse
+mouse_xterm -mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg
+path_extra -perl +persistent_undo +postscript +printer -profile +python
-python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white +tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/cluster/home/jstjohn/share/vim"
Compilation: gcc44 -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -I/usr/include -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1
Linking: gcc44 -L/usr/local/lib -Wl,--as-needed -o vim -lm -lncurses -lnsl -lselinux -L/hive/groups/recon/local/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -L/usr/lib -ltcl8.4 -ldl -lpthread -lieee -lm
You most likely need to set backspace+=start. Generally you probably want set backspace=indent,eol,start, but just "start" should solve this problem specifically.
See :help 'backspace' for more information on the other options.

GNU Screen and Vim: Adjusting the split window buffer size with mouse

When working on GNU screen with Vim, I am not able to adjust the split window sizes with mouse. All the rest mouse actions work fine in Vim (scrolling, selecting text, etc with mouse).I generally have se mouse=n in my .vimrc. Adjusting the window buffer sizes outside GNU screen works perfectly fine.
Here is the vim information:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jan 19 2012 18:05:29)
Included patches: 1-401
Compiled by root#arun-mu
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments -conceal +cryptv +cscope +cursorbind
+cursorshape +dialog_con +diff +digraphs -dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input -iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape -mouse_dec -mouse_gpm -mouse_jsbterm
-mouse_netterm -mouse_sysmouse +mouse_xterm -mouse_urxvt -multi_byte +multi_lang -mzscheme +netbeans_intg +path_extra -perl +persistent_undo +postscript +printer -profile -python -python3
+quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset -xim +xsmp_interact
+xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -lncurses -lnsl
GNU screen information:
4.00.03 (FAU) 23-Oct-06
This did the trick for me. Mouse is completely active inside vim in GNU screen.
:set ttymouse=xterm2
I use vim 7.3, GNU screen (Ubuntu/debian current package versions) and gnome-terminal, and I can use the mouse for dragging window splits just fine when running with
:se mouse=a

Resources