How to Set ‘vi’ as Default Editor in UNIX

vivim

I believe I can do something like export EDITOR=vi, but I'm not sure what exactly to enter, and where.

How can I set "vi" as my default editor?

Best Answer

You should add it to your shell’s configuration file. For Bash, this is ~/.bashrc or ~/.bash_profile. You should also set $VISUAL, as some programs (correctly) use that instead of $EDITOR (see VISUAL vs. EDITOR). Additionally, unless you know why, you should set it to vim instead of vi.

TL;DR, add the following to your shell configuration (probably ~/.bashrc):

export VISUAL=vim
export EDITOR="$VISUAL"