__vi_internal_vim_alias() ( # run vim if installed test -f /usr/bin/vim && exec /usr/bin/vim "$@" # run vi otherwise test -f /usr/bin/vi && exec /usr/bin/vi "$@" ) __view_internal_vim_alias() ( # run vim -R instead of view if vim installed test -f /usr/bin/vim && exec /usr/bin/vim -R "$@" # run view otherwise test -f /usr/bin/view && exec /usr/bin/view "$@" ) if [ -n "${BASH_VERSION-}" -o -n "${KSH_VERSION-}" -o -n "${ZSH_VERSION-}" ]; then # This will avoid user defined aliases case "$(command -v vim)-$(command -v vi)" in "/usr/bin/vim-/usr/bin/vi" | "-/usr/bin/vi") # apply only when founded vim and vi are in expected dirs from distro # we need to call a shell function to avoid shell restarts when vi/vim # is being installed/uninstalled alias vi=__vi_internal_vim_alias alias view=__view_internal_vim_alias alias vim=__vi_internal_vim_alias ;; esac fi