I am looking to switch to Emacs from Vim and one thing that is keeping me away is that Emacs opens up a separate window of its own when run under X. Can I get the same behavior for Emacs as it does when not run under X? That is, I want Emacs to start the session in the same terminal as the one in which its fired.

Let me know if the question is not clear. Thank in advance!

migrated from stackoverflow.com Dec 3 '09 at 12:01

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


I'm no emacs expert, but this did the trick for me:

emacs -nw
  • 7
    You're right, for the curious -nw is short for --no-window-system which tells emacs not to use its X interface. – Mic Dec 3 '09 at 10:46
  • @Mic: Thanks for the explanation, this way I'll remember what it stands for – Alberto Zaccagni Dec 3 '09 at 10:47

You might prefer starting emacs as emacs --daemon and then using emacsclient -t to edit files. This keeps Emacs loaded in the background, so that you can use Emacs more like vi. Editing sessions will start up instantly, and "quitting" via C-x C-c will just close the current connection. It is very nice.


Although your question has been answered, I would venture to say that this is not the way any regular user would use emacs. Unlike vim, emacs generally has a longer startup time and anyway tends to be running all the time with multiple open buffers. So when you want to do something with emacs in a terminal, you invoke emacsclient -nw (assuming an emacs serverhas been started). Look at How to start to use EmacsClient for details.


If you use bash, you can always add the following to your .bashrc

alias emacs="emacs -nw"

That's saved me a lot of typing (and cursing when I forget to type the switches).


Combining the above answers by Dick Kenny and Alberto Zaccagni you get the following configuration which I use in .bashrc:

alias emacs='emacsclient -nw -c -a ""'

This will try to connect to a runnning emacs daemon. If none is running, it will startup a new one, and then connect using the current terminal window.

From the docs:

-a EDITOR, --alternate-editor=EDITOR
        Editor to fallback to if the server is not running
        If EDITOR is the empty string, start Emacs in daemon
        mode and try connecting again

-nw, -t, --tty      Open a new Emacs frame on the current terminal

-c, --create-frame  Create a new frame instead of trying to 
                    use the current Emacs frame
  • 1
    When I try this command, Emacs fails to start, instead giving me a warning about there not being a server to connect to, followed by a giant dump of values and Emacs not starting. – Koz Ross Apr 7 '16 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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