if test $(which sublime)
then
  export EDITOR='sublime'
else
  export EDITOR='nano'
fi

if (( $+commands[sublim] )); then
  export EDITOR='sublime'
elif (( $+commands[nano] )); then
  export EDITOR='nano'
elif (( $+commands[vim] )); then
  export EDITOR='vim'
else
  export EDITOR='vi'
fi

Fix and improve editor selection
Fix and improve editor selection
