Vim seems to get stuck when writing a file - vim

I am using Terminal.app in OSX and Vim. Every time I try to write/save a particular file (it happens to be a .scss file) Vim seems to just hang. I know it successfully writes the file but it never gives me back control. Instead I see the file name at the bottom with the cursor flashing at the end of the line. I have tried Ctrl-Esc, Ctrl-c and Ctrl-[ all to no avail.
If I then quit Terminal.app and reopen it, I can see that the Vim process that got stuck is still running in Activity Monitor.
I am able to write other files just fine.
I am also using CodeKit to watch the .scss files but thinking that might be the cause, I quit CodeKit and tried to write the file again with Vim but it still got stuck.
It does seem to write correctly if I use MacVim, it just doesn't seem to work via Terminal.app.
Any suggestions would be much appreciated, thank you!
EDIT
Here is my current .vimrc: https://www.dropbox.com/s/1r72shv47f07crs/.vimrc
I'm using Vim 7.3, here are the details:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 20 2012 13:16:02)
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 all that's in my .bash_profile:
# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'

I finally found the cause of the problem. It did have to do with file permissions. I created a new test.scss file in the same directory and was able to save changes to it just fine using vim in Terminal.app. I then compared the permissions of the test.scss file and my main style.scss file that was causing me trouble. The results looked like this:
test.scss
-rwx------
and for style.scss (the file that was causing me trouble)
-rwx------#
I suspect that CodeKit had added some additional file attributes to the file when it was initially scanned (by CodeKit) and that these extra attributes (as indicated by the #) were the culprit. This would explain why I was still experiencing the problem even when CodeKit wasn't running. I used the xattr command to inspect the additional attribute which gave me com.apple.ResourceFork. I then used xattr with the -d flag to remove this additional attribute from the file and the problem was fixed.
xattr -d com.apple.ResourceFork style.scss
I suspect that this is a pretty obscure and specific situation but hopefully its helpful to someone else as well.

What version of Vim are you running? Perhaps updating it might fix the bug.
The only other things that I think would cause Vim to choke on something as common as saving a file would be conflicts from plugins or any big custom functions in the .vimrc.
If you could give some more detailed information, I might be able to help more.

The default Vim as always sucked on Mac OS X.
Thankfully, MacVim comes with a mvim executable script that allows you to use MacVim in your shell. Place it somewhere in your $PATH and do $ mvim -v filename. If the problem only happens when you use /usr/bin/vim this might solve it.
Do you have the syntastic plugin?

Related

How to correctly install YouCompleteMe on mac?

I have the following line in ~/.vimrc
Plugin 'valloric/youcompleteme'
Running PluginInstall successfully installed the plugin.
Then I ran python3 install.py --clang-completer under /Users/$UserName/.vim/bundle/youcompleteme.
Running vim gave me:
YouCompleteMe unavailable: requires Vim compiled with Python (3.5.1+) support.
The python3 version is 3.6.8.
vim --version shows that it has python3 support:
VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 13 2019 14:45:40)
Included patches: 1-503, 505-680, 682-1312
Compiled by root#apple.com
Normal version without GUI. Features included (+) or not (-):
+acl +extra_search -mouse_netterm -tag_old_static
-arabic -farsi +mouse_sgr -tag_any_white
+autocmd +file_in_path -mouse_sysmouse -tcl
+autochdir +find_in_path -mouse_urxvt -termguicolors
-autoservername +float +mouse_xterm +terminal
-balloon_eval +folding +multi_byte +terminfo
-balloon_eval_term -footer +multi_lang +termresponse
-browse +fork() -mzscheme +textobjects
+builtin_terms -gettext +netbeans_intg +textprop
+byte_offset -hangul_input +num64 +timers
+channel +iconv +packages +title
+cindent +insert_expand +path_extra -toolbar
-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/dyn +visualextra
-conceal +linebreak -python3 +viminfo
+cryptv +lispindent +quickfix +vreplace
+cscope +listcmds +reltime +wildignore
+cursorbind +localmap -rightleft +wildmenu
+cursorshape -lua +ruby/dyn +windows
+dialog_con +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
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -o vim -lm -lncurses -liconv -framework Cocoa
I use YouCompleteMe for C and built vim 8.2 from source on my mac with OSX 10.15. If you want to use it for c-family languages it's pretty finicky. You might spend a lot of time reading posts like these, ones where someone was having a different issue 3 months ago and there's no answer.
To build vim with python3 support you can do one of two things,
git clone https://github.com/vim/vim.git
cd vim
git pull
cd src
make distclean
./configure --with-features=huge
make
sudo make install
This will give you more than just python3. There aren't any drawbacks to having the extra features as far as I know.
my vim is installed in $HOME, I think the install script symlinked the binary to /usr/local/bin/vim.
or you can use homebrew and macvim which is what I would recommend,
brew install macvim
sources:
https://www.vim.org/git.php
https://vim.fandom.com/wiki/Building_Vim
YouCompleteMe need that VIM, that VIM must support Python3.
(That means that you need to use Python3 to config installling VIM).
As your VIM 's "vim --version" shows, your installed VIM Do Not Support
Python3(Beacuse the symbol before python3 is that '-', that '-' minus
means Your installed VIM do not support python3).
Even your Mac defualt python3 is over 3.5.1,
your installed VIM support python#2(from "+python/dyn" sa your "vim --version" shows).
Please use Homebrew reinstall VIM with supporting python3,
DO NOT USE your Mac default installed VIM.
Could refer:
0.Installing Vim with Python3 support on MacOS.
1.Debian Manually install VIM which suppoet Python3.
2.How do I install vim on OSX with Python 3 support?

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 Crashes on saves and quits

New to programming (and SO) so I may be missing some very basic step, but this is happening with multiple other people I work with.
Very commonly in vim when I have multiple buffers open, if I :w or run any quit command (:q!, ZZ, :wq, etc) the program will crash, only displaying this message:
Vim: Caught deadly signal ABRT
Vim: preserving files...
Vim: Finished.
[1] 20271 abort vim .
%
Attempts I've taken, with no luck:
Deleted .swp file
Update vim by overriding the system version
Info of my Vim install (through homebrew)
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Nov 5 2014 21:00:28)
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
If you need more information let me know. Any help would be greatly appreciated!
You might not be using the version you installed since the compile date is November 2014. Try the following:
brew uninstall macvim
brew install macvim --override-system-vim

is there a suggested "best" location for a global .vim dir

I am setting up a single pc running xubuntu which several people will use. Although I may well be the only one who uses vim, rather than install a .vim dir in each user's ~ is there a better path the folder can be stored and so loaded whenever vim is fired up no matter on which user's account?
I found lots of advice regarding a global .vimrc file but next to nothing regarding a global .vim dir.
That path has to satisfy two requirements:
it must already be in 'runtimepath' so that the configuration is picked up by default, i.e. without individual users having to modify their ~/.vimrc
it must not be occupied by files that ship with Vim, so that you don't run into problems when updating
On my Ubuntu 13.10, there's /usr/share/vim/vim74, which contains Vim's runtime (so off-limits), and the /usr/share/vim/vimfiles, which is symlinked to /etc/vim. I'd suggest putting global plugins into the latter, i.e. /etc/vim/plugin/.
if you try help VIMDIR then you could see that the command :version gives you the path you're after. Apparently this is set at compile time.
On my machine "osx" it set to "/usr/share/vim"
:version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 24 2013 18:58:47)
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

Vim: Automatically leave insert mode after some time

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.

Resources