Vi is aliased to vim but exit with code 1


This is a weird return code even I have aliased vi by vim.

I really appreciate if anyone could explain me why.

Check my commands and results below.

<ul><li>which vi returns /usr/bin/vi</li> <li>which vim returns /usr/bin/vim</li> <li>

ls -al /usr/bin/vi /usr/bin/vim returns

lrwxr-xr-x 1 root wheel 3 Dec 15 03:34 /usr/bin/vi -> vim -rwxr-xr-x 1 root wheel 1745984 Dec 10 18:03 /usr/bin/vim </li> <li>

cat ~/.vimrc returns

set nocompatible silent! unmap <C-E> </li> <li>

vim then :q to quit immediately. Then echo $? returns 0

</li> <li>vi then :q to quite immediately. <strong>But problem is here</strong>, echo $? returns 1</li> <li>And <strong>if second line in .vimrc, i.e. silent! unmap <C-E>, is removed</strong>, vi, :q, echo $? returns 0</li> <li>

vi then :version prints

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 5 2016 16:04:34) Included patches: 1-898 Compiled by root@apple.com Normal version without GUI. Features included (+) or not (-): +acl +cindent -conceal +digraphs -farsi -gettext +libcall +mksession -mouse_netterm -mzscheme -profile +scrollbind +syntax +textobjects +visualextra -X11 -arabic -clientserver +cryptv -dnd +file_in_path -hangul_input +linebreak +modify_fname -mouse_sgr +netbeans_intg +python/dyn +signs +tag_binary +title +viminfo -xfontset +autocmd -clipboard +cscope -ebcdic +find_in_path +iconv +lispindent +mouse -mouse_sysmouse +path_extra -python3 +smartindent +tag_old_static -toolbar +vreplace -xim -balloon_eval +cmdline_compl +cursorbind -emacs_tags +float +insert_expand +listcmds -mouseshape -mouse_urxvt -perl +quickfix -sniff -tag_any_white +user_commands +wildignore -xsmp -browse +cmdline_hist +cursorshape +eval +folding +jumplist +localmap -mouse_dec +mouse_xterm +persistent_undo +reltime +startuptime -tcl +vertsplit +wildmenu -xterm_clipboard +builtin_terms +cmdline_info +dialog_con +ex_extra -footer -keymap -lua -mouse_gpm +multi_byte +postscript -rightleft +statusline +terminfo +virtualedit +windows -xterm_save +byte_offset +comments +diff +extra_search +fork() -langmap +menu -mouse_jsbterm +multi_lang +printer +ruby/dyn -sun_workshop +termresponse +visual +writebackup -xpm system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/usr/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 -o vim -lm -lncurses -liconv </li> <li>

I had tried iTerm, Terminal, changed shell to bash, zsh, fish. Remove first line, set nocompatible, in .vimrc. But they all returned this result.

</li> </ul>

If you need more config in my PC, please give a comment, I will provide it.

Thanks in advance.

<hr />


Because I opened new shell based on the current shell, via command like zsh, bash. It ignored my .zshrc/.bash_profile.

Thus, $PATH does not include /usr/local/bin. Then, instead of using homebrew vim 8.0 version. which vim pointed to default MacOS /usr/bin/vim version.

After trying opening open new shell by command-T and ensure that which vim returns /usr/local/bin/vim, i.e. homebrew's version. vi, :q, echo $? echoed expected result 0.

This solved my problem of exit code 1 after exiting vi, this affected git commit command ..etc. But I still do not understand why default MacOS version of vi makes this unexpected behaviour


You don't need to set to '<em>nocompatible</em>' to Vim because this is the default setting.

I remove this feature in my MacOS and works fine and with exit status 0, writing or not writing files.

Note: is MacOS 'vi' is a link to 'Vim' (and 'awk' is actually 'gawk')

Conclusion: you may use

silent! unmap <C-E>

in your <em>.vimrc</em> file and vim may not exit with error.


  • MATLAB - video processing
  • Menu Icon is not showing in Android
  • Force directed layout for constrained rectangular shapes
  • Visual studio 2017 and the cl.exe error
  • Require “open-url” load error when executing Nokogiri tester
  • Show list in groups
  • Silverlight DataStateBehavior, initial value not used
  • 'an illegal memory access' when trying to write to a 2D array allocated using cudaMalloc3D
  • The device freezes when there are a lot of UIView animation running with UILabels using shadows and
  • How does Julia using behave on missing package?
  • Numpy: Retriving an array from an array of pointers
  • Application launcher icon being displayed on action bar of an activity
  • Installing bitarray in Python 2.6 on Windows
  • Changing the size of cells in grid view?
  • iText Merge PDF with cropbox
  • Lost dynamically added click events to each TableCell in each TableRow
  • strophe.js with http-bind failed to load resource 404 not found
  • Vaadin Table does not update no matter what I try
  • Rgdal package installation on Amazon Linux AMI
  • vim filetype plugin conflict with session
  • Linux - Error loading rJava in Rstudio: libjvm.so: missing?
  • C# Sharepoint cannot retreive items from list programmatically
  • saving/restoring buffers not working in vim
  • Converting int, double to char array in C or Objective C
  • Receiving data from multiple devices using parallel wired RS232
  • mysql doesnt return proper json
  • Calling R from Matlab
  • prolog I have to make a program that calculates the magic matrix permutate
  • Printing list elements and strings in Python have different results
  • Is there a manual for the run command in crashlytics framework
  • Formatting a TimeSpan to look like a time zone offset
  • Is there a way to use Firebase Legacy console from new account
  • How to make a user wait with Laravel
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • where do I find the xml.dom python package for the python-2.6.0-8.9.28 and I have a suse/x86_64 vers
  • Python pickle not one-to-one: different pickles give same object
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Display issues when we change from one jquery mobile page to another in firefox
  • To display the title for the current loaction in map in iphone
  • trying to dynamically update Highchart column chart but series undefined