Super User is a question and answer site for computer enthusiasts and power users. 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

It seems it' ok to use 'EDITOR=emacs',it open GUI emacs. If I use 'EDITOR=emacs -nw', it fails.

share|improve this question
up vote 3 down vote accepted

There are many programs that launch an editor based on the EDITOR environment variable. Unfortunately, they disagree on whether that variable should contain a shell script snippet (so that you can pass options to the editor), or should contain the name of an executable file (which may happen to contain spaces).

The safe option is to write a short script that calls your editor with the options you want and give it a name that doesn't include any special characters. Here's a sample script:

exec emacs -nw "$@"

Call that script /home/chenge/bin/EDITOR (for example) and set EDITOR=/home/chenge/bin/EDITOR.

Also set VISUAL to the same value (the two variables have the same purpose; most but not all programs understand both).

By the way, if you have Emacs 23, you may want to set up the Emacs daemon and call emacsclient instead of emacs.

share|improve this answer
Thanks,it works. I used emacsclient, but it has some problem while display Chinese chars in utf-8. – chenge Jul 22 '10 at 3:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .