Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I generally set both VISUAL and EDITOR environment variables to the same thing, but what's the difference? Why would I set them differently? When developing apps, why should I choose to look at VISUAL before EDITOR or vice versa?

share|improve this question

2 Answers 2

up vote 61 down vote accepted

The EDITOR editor should be able to work without use of "advanced" terminal functionality (like old ed or ex mode of vi). It was used on teletype terminals.

A VISUAL editor could be a full screen editor as vi or emacs.

E.g. if you invoke an editor through bash (using C-x C-e), bash will try first VISUAL editor and then, if VISUAL fails (because terminal does not support a full-screen editor), it tries EDITOR.

Nowadays, you can leave EDITOR unset or set it to vi -e.

share|improve this answer
Most applications treat $VISUAL as a shell snippet that they append the (shell-quoted) file name to, but some treat it as the name of an executable which they may or may not search in $PATH. So it's best to set VISUAL (and EDITOR) to the full path to an executable (which could be a wrapper script if you want e.g. options). –  Gilles Dec 15 '10 at 18:27
In modern times, ed and similar are not very popular so I believe it is OK to just ignore VISUAL and use EDITOR. –  Pavel Šimerda Mar 30 '14 at 17:35
Thanks for the tip about C-x C-e in bash. Very handy. –  mndrix Mar 25 at 19:22
@PavelŠimerda, just setting EDITOR is not enough e.g. for git on Ubuntu 12.04. Without VISUAL being set git ignores EDITOR and just uses nano (the compiled in default, I guess). –  maxschlepzig Apr 25 at 10:24
@jacwah, this is why I wrote 'is not enough e.g. for git on Ubuntu 12.04'. I mentioned Ubuntu 12.04 as a concrete example where just setting EDITOR is not enough - at least when you are using git there. And this behavior matches the historical distinction correctly described by 'andcoz'. –  maxschlepzig Jun 28 at 7:01

Since there don't seem to be any environments where vi or similar would fail, I've taken to setting VISUAL to something that needs an X DISPLAY, and EDITOR to ex.

Mostly, that just seems to cause me problems when some program doesn't use VISUAL.

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.