I am currently interested in switching from vim to emacs.

One of the more compelling reasons for this is the smooth integration with a unix environment. The most experienced emacs users I have seen have a bash prompt at the bottom of their window, with stdout going to a buffer right above it. They then interact with the output of programs such as grep in interesting ways.

I am on Ubuntu 10.04 and the default emacs environment does not seem to do much for me in the way of integration. For example, in the M-x shell mode, output from basic commands like ls produce lots of strange characters and hitting the up arrow does not go to previous commands.

Any recommendations on a good direction to go in?

migrated from stackoverflow.com Mar 13 '11 at 14:18

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


Regarding how to go about getting a decent setup you can go two different ways:

  1. blindly use customizations from other people/web pages (e.g. Emacs starter kit)
  2. actually think about what you want, ask questions, learn, and customize your .emacs yourself

In my experience, many take the first route, and that's fine. You get some handy customizations with little work. However, you don't really know any more than you did before you did the big cut/paste.

If you take the time and ask questions (like you did about shell and ls), you'll end up with a customized Emcas experience that actually meets your needs. Plus, you'll have a much better idea of what is possible and how you can get there. The downside is that it takes a litle work (not much, but it's non-zero and that scares many).

So, to start you off down the path of enlightenment (if you decide to take the red pill), I'll give solutions to your particular issue. Note: With so little information about your setup, I'll make some educated guesses about your specific problems.

The ls is showing all sorts of funky characters because you have the ls command output special characters for colors in your regular terminals (perhaps you have it aliased to ls --color). M-x term does handle this correctly, but this also works:


Instead of using the arrow keys, you can use M-p and M-n to go to previous/next commands. Or, you can bind the arrow keys to do what you want:

(add-hook 'shell-mode-hook
      (lambda ()
    (define-key shell-mode-map (kbd "<up>") 'comint-previous-input)
    (define-key shell-mode-map (kbd "<down>") 'comint-next-input)))
  • Great! M-p and M-n are the types of things I should be looking for. Also, knowing about the key-bindings is very nice. I do believe this is going to be a long migration... I thank you for helping me understand this. Thanks! – Hersheezy Mar 15 '11 at 0:12

You might want to try eshell (M-x eshell), or you may want to read up on the commands and shortcuts for the shell command (M-x shell). eshell is a shell written in emacs lisp that integrates almost flawlessly with Emacs. My only complaint is that it's not as fast as the normal shell.

As for getting everything else set up, I recommend the emacs starter kit, which contains a number of useful scripts and elisp modules to extend and configure emacs.

Emacs is an acquired taste. The people that you have watched likely have decades of emacs experience -- they started out just as clueless as you. I'd recommend you try and read a few books on the subject -- Learning GNU Emacs is what I learned from, and after that the GNU Emacs manual is a great guide and reference.

  • Excellent! The eshell as well as the starter kit are getting me well along my way :) Also, it is true that the emacs users I refer to have O(decades) of experience... – Hersheezy Mar 11 '11 at 5:40
  • 1
    @Hersheezy good news is that you're on your way, too. Another great productivity tool in emacs is org-mode, once you get a handle on everything else you should check that out. – Rafe Kettler Mar 11 '11 at 5:42
  • 1
    After decades of emacs use, you tend to forget that "emacs out of the box" is "different" from the emacs you work with every day. – klang Mar 11 '11 at 15:59
  • +1 eshell is great!!! M-x term and M-x shell have been frustrating because they over-ride many of the standard key-bindings and have odd quirks e.g. when displaying the results of more, man, etc. – David LeBauer Jul 14 '11 at 17:52

It's interesting to me that your reason for switching from vim to emacs is about Unix integration, and how you've seen emacs folk with shell buffers etc., as it's telling of your experience level with these two editors in general. Neither emacs nor vim come "out of the box" the way that you'd like them but rather act as platforms on which to develop a work flow.

For example, vim doesn't come with the functionality you describe out of the box, but plugins like conque and addon-async, much the same way emacs doesn't. Rather, it starts with (the same as emacs -- via M-!) the ability to run an outside command and pipe that into a new buffer (:r! command).

I'm not here to dissuade you from emacs, but rather suggest that the best way to learn either of these is to pick one and dive in. If you have friends who know emacs, ask for their config files. Ask what plugins you might like, or how to get specific functionality. The hardest question for those with experience to answer is "What should I do next?"

As previously stated, the emacs starter kit is great, as well as the peepcode screencast from whence it came. In addition, much of Learning GNU Emacs is available free online via Google Books. As for actual plugins I use, I happen to like anything.el for code-completion and autopair.el to put matching braces in. Also, have a gander through marmalade for things that might be of interest to the languages and environments you work in. This will lead you to more guided questions about specific functionality.

Good luck in your editing quest!

  • Thanks for the suggestion :) I am a fairly experienced vim user and have been using conque for a while now. While very nice, it has never really felt very integrated to me. I did not know about addon-async though, thanks for the heads up! – Hersheezy Mar 15 '11 at 0:16

Use M-x ansi-term instead of M-x shell - that way you'll have a real terminal emulator in Emacs. It's not perfect, but it certainly fares better with curses applications such as mutt, top, etc.

I'd also recommend you to have a look at the Emacs Dev Kit - a lesser known alternative to the Emacs starter kit. Albeit in alpha version it has a lot of useful configuration in it that can be readily reused.

You should also have a look at the Emacs Wiki and Mastering Emacs.

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.