Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from stackoverflow.com Apr 24 '13 at 0:43

This question came from our site for professional and enthusiast programmers.

just export EDITOR=vim in your bashrc or zshrc or ..rc – Kent Apr 23 '13 at 23:31
often must be set up for programs in addition to this such as git – timpone Apr 24 '13 at 0:39
up vote 54 down vote accepted

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
share|improve this answer
I wouldn't call 4 lines as too long. – ott-- Jun 1 at 18:48

You could also set your default text editor by using the following command.

sudo update-alternatives --config editor
share|improve this answer
This set the default for git too, which was exactly what I needed. – Kzqai Mar 9 at 18:26

Drop it in your home directory .bash_profile

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.