Diving Into…
I started using Emacs as a Linux IDE for a C++ project. At that moment I was also using IntelliJ IDEA for my personal Java project and wondered if I could have a comparable environment for C++ under Linux. My first try was to use Eclipse with CDT, but the experience was frustrating—CDT was slower than IDEA and in addition uncomfortable. The main reason for slowness was that CDT tried to do honest parsing of all our project and imported headers. Also it was failing miserably on some non-trivial parts due to high complexity of C++ itself.
Obviously, I needed something more lightweight, albeit not very primitive. By that time I already had had a positive experience of Windows development using only FAR’s built-in editor accompanied by some plugins, mainly Colorer and AutoCompletion. So, what about simple yet powerful programmer’s editors for Unix?
As everybody knows, there are lots of Unix-based editors that real programmers use, of which two can be viewed as IDEs: Emacs and Vim. I chose Emacs based on editors comparison done by Eric Raymond in “The Art of Unix programming” book and Steve Yegge’s evangelical posts on Emacs (see links in the last section). Mainly, I didn’t like the idea of interaction modes in Vim. As Jef Raskin said in his book “The Humane Interface”: “Modes are a significant source of errors, confusion, unnecessary restrictions, and complexity in interfaces”
This made my choice. So I grabbed “Learning GNU Emacs” and “GNU Emacs Manual” and dove into. It took just about an hour do learn the basic stuff. What amazed me first in Emacs is the idea of ubiquitous text buffers. Everything in Emacs is a text buffer. Thus, you can trivially transfer contents between them and use the same commands for editing and navigation. And the greatest benefit is that you can use search just everywhere. This is much more productive as opposed to “common” IDEs, where you have tree and list views, pop-up boxes, wizards and other stuff, all having different interaction behavior and abilities.
The Real Project
Having a confidence that Emacs is really useable and convenient, I started using it for a C++ project. Again, I was pleasantly surprised how good is Emacs at C++ coloring and indenting. Then, I attached etags, and this covered 90% of my auto-completion needs. Really, you don’t need to do a sophisticated parsing of source code in order to do good enough auto-completion.
So, using Emacs, I was able to do comfortable editing of C++ sources, Makefiles, SQL files, shell scripts and all other stuff that we used in the project. It was also easy to compile the project and navigate back to errors in the source code, do project-wide searching and perform non-trivial renamings with regexp search and replace. I was also talking to our version control system from Emacs. And all this by means of text buffers.
Extensions, Extensions, Extensions!
In parallel to my main project, I was also studying functional programming in Haskell and Scheme. Immediately I found excellent Emacs editor extensions for both (in Emacs, extensions are called “modes”, but they are not those evil interaction modes that are used in Vim) [Note: I've seen people complaining that Emacs' modes are "evil modes" too, because your keyboard gestures are dependent on the current mode. That's correct. But in Emacs mode is connected to a buffer, and you know in what buffer you are now. While in Vim, you switch mode, while staying in the same editing window. I find this confusing, and other people too.] This is what really amuses me in Emacs—name any programming language, version control system, feature of shell, whatever—and you always can find an extension to Emacs which allows you to interact with it. Really, “good ol’ C-x M-c M-butterfly…” in action!
For examples of Emacs extensions varieties, take a look at EmacsWiki. Thousands of people are publishing their extensions and short code snippets in Emacs Lisp that can solve any particular task. What’s really amazing is the wise Emacs internal architecture that allows those myriads of extensions to work together. Eclipse tries hard to achieve this, and the concept of plugin extension points is really similar to “hooks” in Emacs, but… But it’s almost impossible to write a useful Eclipse extension with just a few lines of Java code—too many low-level overhead. While in Emacs, you just write several lines of Emacs Lisp code and it works, and you can publish it, and everybody can just paste your code, and now it works for them, too (well, of course, I’m idealizing—but often this is true).
You’ll never finish learning Emacs—it is a really deep barrel of extensions. I always find something new in it. For example, here are my recent discoveries: the windmove package that allows you to navigate between tiled editing buffers easily; mmm for text coloring and indenting in mixed-language files like html with javascript, jsp, C++ withinline assembler, etc; good ol’ ediff that has features of highlighting changes inside line and dynamically re-comparing files as long as you editing one of them.
And these are really well-known and obvious extensions, for using Emacs as an editor. But I know people who literally live in Emacs. They read mail and news in it, organize their time and projects, surf the Web, write their blog posts, chat using IM extensions and use many-many more features including awesome Emacs’ interface for visually impaired people.
How Should I Start?
So, what can you read to study Emacs? You can begin with inspiring Steve’s articles: “My .emacs file”, “Tour de Babel” (here search for “Lisp”), “Effective Emacs”, “Saving Time”; read introductory pages of EmacsWiki; take a look at blogs dedicated to Emacs: minor emacs wizardry and M-x all-things-emacs; and don’t forget about built-in “info” system in Emacs itself.
As for the books, you can grab Richard Stallman’s GNU Emacs Manual for free, and read through “Learning GNU Emacs” and “GNU Emacs Pocket Reference”.
And the last tip: as Emacs is very keyboard-intensive, the first thing that you need is a good cheatsheet for keyboard combos. Although I’ve seen many over the Web, the one that I like the most is that I made myself. Here it is.
Happy emacsing!




17 Comments
Don’t you have to be like a pianist – long and flexible fingers to be able to use all those C- M- shortcuts without a pain? :)
I’ve tried Emacs but found that on my two keyboards it’s not really comfortable for me to navigate thru a text with C-b,f,p,n etc. Maybe I have Ctrl in a wrong place. So I’ve switched to Vim. ;) But I believe Emacs is a good… um… OS that happens to be an editor as well. :) I’m just kidding, I don’t have anything against Emacs.
Happy emacsing indeed!
You really don’t need to navigate using C-b,f,p,n. All modern Emacses support arrow keys and mouse. Emacs make use of key shortcuts as every professional application. Even in Photoshop, if you want to work fast, you need to stick to their key combos. Ok, maybe Vim overcomes this by means of modes :)
Yes, making CapsLock to become Ctrl key is helpful, but not only in Emacs. I found that this makes work easier in every application—even in Microsoft Word. The only drawback is that when you want to do something on somebody’s workstation, you need to re-adjust yourself to avoid pressing CapsLock ;)
I also don’t have anything against Vim. Just wanted to inform people about alternatives.
Hi! I’m a vim-mer and as I don’t belive in software holy wars I started learning using Emacs. The very first impression I had is that the first steps in Emacs are more difficult than the corresponding ones in Vim… and the documentation doesn’t help. Uhm… let’s say: how would you create, edit and save a new text file from scratch? In Vim it’s quite simple: run vim, press “i” and you will be able to insert your text, write whatever you want, press “ESC” and you will be able to type commands, type “:w “.
Note that I haven’t used Vim-related words *at all* (insert mode, command mode,…).
Now try to explain the same operation with a totally-newbie-and-dummy-proof language for Emacs… maybe that’s because I’m a totally-newbie-and-dummy, but, really, I still have problems with those /primitive/ operations…
;-)
(-_-)
In Emacs it’s quite simple: do not press anything to write whatever you want, press M-x (that’s Alt-x) and you will be able to type commands, type “save-buffer”.
Inserting text and giving commands are so intertwined that I cannot work with modes.
Going back into command mode just to delete a character is highly frustrating to me.
Unless you write all your text without faults the first time… I certainly don’t.
Could it be that people have an innate editing behaviour, at least two main strands of which exist, catered by two different editors?
Niels: I totally see your point about mode switching. It’s inconvenient sometimes.
However, I’ve found I myself do separate the two activities: I either give commands mostly, or I edit mostly. When you are in edit mostly mode, you still have access to the most common commands just like emacs does: Via control shortcuts.
For more extensive command editing, I myself found going back to command mode for easy command access is more comfortable than pressing modifier keys.
I speculate that what one prefers may be intimately tied to whether one touch types or not. I do, and I am loath to leave the home row.
PS. You don’t go back into command mode just to delete a character. You press backspace…
Indeed, I have been using Emacs for past 5 to 6 years and windmove is new to me. Thanks for the tip.
“Everything in Emacs is a text buffer.”
This is very interesting. Can you elaborate some more on this? Any links?
@Giulio You could just write in the default scratch buffer and hit Ctrl+X, Ctrl+W to save to a file. I think emacs is much easier to pick up than vim because most programs use modifiers for hotkeys instead of using modes. vim is almost certainly faster when you’ve gotten good at it, but emacs is probably easier to learn
TextMate is what you’re looking for, I think … for Windows, the wonderfully-named E-TextEditor claims to be equivalent.
I don’t know, as I’ve not tried, but it could be worth a go.
Lovvve the cartoon, though. Haha, butterflies. I’m going to have to try that.
@David: I have TextMate and use it occasionally it’s a great editor it almost does everything I want except Vim key bindings. :) I don’t really like to move my hand to arrow keys for navigation, I like to stay close to my “home row” and I guess my fingers are not strong enough to press C-f, C-b, C-n so that’s why I’ve been lately using Vim. Opps… isn’t this post about Emacs? :)
@Niels: I agree with you that different kinds of editors and IDEs do exist because different people have different views on what is called “simple” and “intuitive”.
@Ed Davis: Please see this entry from the manual: http://www.gnu.org/software/emacs/elisp-manual/html_node/Buffer-Type.html#Buffer-Type and this intro to Emacs: http://xkahn.zoned.net/help/emacs.html (see “Buffers and Files” section)
@Michael Mrozek: Umm, people are often complaining that Emacs has a steep learning curve. I think that much of it comes from an “alien” terminology: “Meta key”, “buffer”, “yank”, “kill”, “find-file” etc.
@Danil: Ok, if you do use blind typing then moving hand to arrows keys is unproductive for you. But you still can try making CapsLock a Ctrl (anyway you don’t use CapsLock much, right?). BTW, Emacs has got these key combos because it was developed for the “Space Cadet” keyboard (http://en.wikipedia.org/wiki/Space-cadet_keyboard) which has Ctrl near the Space.
@Mikhail: You’re a Mac user these days, aren’t you? What Emacs distribution do you use? Can you give any recommendation?
I’ve tried 3 Emacs distros for Mac.
The first one is “pure” GNU Emacs that is bundled with OS X. You can run it in the Terminal app by typing “emacs”. Its main drawback, however, is that it lacks X window graphics support, which makes some convenient key combos (like Alt or Shift + Arrow keys) nonfunctional. But of course all classic combos work.
The second one that I tried was Aquamacs (http://aquamacs.org/). To me, it was very heavy and also it crashed often. So I dismissed it.
Finally, I’ve stuck to Carbon Emacs (http://www.apple.com/downloads/macosx/unix_open_source/carbonemacspackage.html). It is light, graphical and stable. I recommend it.
If you’re going to give it a try, you can also look at the main part of my .emacs here: http://nmv.tiddlyspot.com/#EmacsConfiguration . It contains some convenient options not enabled by default.
imyvistory I really like vi, it’s a pretty cool editr. It has all these neat:%s/editr/editor/IiI really like to use it. I don’t understand why people would use emacs.:x Changes made to file, use ! to force :x!
:P
http://catb.org/~esr/jargon/html/graphics/73-05-19.png
It’s definitely worth learning emacs key bindings as you can use some of them in other apps where you have to enter text , e.g. firefox’s address bar, Terminal & TextEdit on Mac OSX .
The ones that usually work are:
C-a e d k f b w