Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim seems to get stuck when writing a file

Tags:

terminal

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 [email protected]
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'
like image 415
themarkappleby Avatar asked Oct 07 '22 10:10

themarkappleby


1 Answers

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.

like image 115
themarkappleby Avatar answered Oct 10 '22 12:10

themarkappleby