
Ask YC: Why is emacs a great editor? - mixmax
I recently installed emacs since a lot of people (yes - yc users) seem to think it is the best code editor around. I read that it has a steep learning curve, but that it would be worth the effort. I accepted that and started using it as my primary editor to get my hands dirty. After 2 weeks of use I'm still not productive in it. I can think of the following reasons for this:<p>- I use my mouse a lot, and it seems that emacs is made primarily for keyboard input. I don't use keyboard shortcuts much.<p>- A nice looking GUI and well designed intuitive interfaces matter to me. Emacs is extremely lacking in this respect.<p>- I simply haven't spent enough time with it - the learning curve is steeper than initially expected.<p>What do you think? Am I missing something obvious, should I carry on in the belief that this is a divine tool that just takes time to master, or is emacs simply not for me?
======
mechanical_fish
Have you read O'Reilly's _Learning Emacs_? I strongly recommend it. It's a
useful tour guide.

Failing that, have you read the tutorial?

Have you read Steve Yegge's "Effective Emacs"?

If none of that can help or inspire you then I probably don't have much
chance. But I'll offer you some coaching anyway. Imagine Vince Lombardi
reading this to you:

Stop using the mouse. If you're using emacs and you're touching the mouse,
you're doing it wrong.

Stop fretting about the GUI. Why does your editor need a GUI? Emacs is a _text
editor_ , a program that is all about _text_. It's _text_ all the way down. If
it had more chrome, that would be wasting pixels that _could be devoted to
text_. (Seriously: As Yegge will tell you, the true emacs user turns _off_ the
pull-down menus to make more room for text.)

Stop worrying about "intuitive". Yes, until you get to know the moves, emacs
is nonintuitive, kind of like the piano. No matter how expensive and well-
designed a piano I buy, I won't be able to just sit down and play some Chopin.
(Well, technically you can buy player pianos that will do just that, but what
would a concert pianist call such an instrument? _A toy_.) You're learning an
open-source text editor that's quite possibly older than you. You will live
with this software for months, years, or decades. You don't need features that
make it easy to learn emacs in five minutes. You need the features that make
it worthwhile to use emacs after thirty years.

And, yes, you haven't spent enough time. In particular, it's not just a matter
of plugging away in emacs for weeks or months; it's unlike any other software
you've ever used, and until you're oriented you won't find it easy to pick up
things just by playing with it. You have to study it a little. Try some of the
references. Try the Emacs Wiki.

~~~
mixmax
I just read Steve Yegge's "Effective Emacs", thanks for the link. It was very
enlightening on many levels and told me several things that were written
between the lines, namely:

\- Initial user experience is (very) secondary to long-term efficiency

\- if you aren't in this for the long term don't bother - the article actually
suggestes swapping the caps lock key and the ctrl key to have it better
positioned for emacs use...

\- unplug your mouse, the keyboard is faster once you learn how to do it well.

It seems to me that Emacs is a friend for life, but only if you have the
patience for a year or two of courting and learning its tweaks and quirks.

I'll buy O'Reillys book and see how it goes.

~~~
ragnemalm
Many are a fan of using the Caps Lock key as Control. While better than the
insane standard positioning, it's still not optimal: it's not symmetrical
between your hands (you're not going to remap Return as another Control) and
it still makes for a lot of awkward pinky use. (Imagine playing a piano piece
all with your 3rd, 4th and 5th fingers.)

The optimal solution I've come up with is to use the two keys adjacent to the
space bar (typically Alt, but actually Command on the Apple keyboard I
generally use) as Control, since that's easily the most important modifier
key, so it should be the easiest to access. This makes C-w, C-s, C-r, C-a,
C-e, C-p, C-o, C-j, C-l and so on very, very comfortable compared to the
corner positioning. As far as I know, this is the way many keyboards were
before the extended IBM PC keyboard came up with its insane control key
positioning. (My comfort with these keys may also be linked to my use of Macs
and ubiquitous command-key shortcuts before I switched to Ubuntu. Ironically,
Emacs is much more comfortable now in Ubuntu than it ever was on my Mac,
because I can use the most readily accessible modifier key as God intended,
rather than the third-tier relegated modifier that Control is on the Mac.)

The two keys adjacent to the new Control keys (ie. 2 away from the spacebar)
then become the Alt keys. Whatever is left over (the original ctrl keys, plus
Caps Lock and any silly Windows keys left over) can be bound to Super, which
is useful for window manager shortcuts so that they don't clobber
emacs/bash/screen bindings.

These changes are trivially easy to put in a simple .Xmodmap file to load
whenever you log in, and copy to all the other computers you have to use
regularly. If you're using Windows, I guess you may have to fiddle with the
registry, but it would be worth it.

~~~
spinonethird
Another solution is to keep the Ctrl keys where they are (note the plural),
but hit them with the side of your hands: you just need to roll you hand a
little bit to the outside. It takes a little practice to do this reliably, but
it cures pinky pain (at least for me).

Use the hand that is not hitting the key: for C-s use your right hand for the
Ctrl, and left for s. C-n the other way round. For Meta, make sure that both
alt keys work, and use your thumbs: M-x right thumb and left fourth finger.

\- You can't do this for C-M combinations, but they are few and far between.

\- You have to have a keyboard where the keys "stick out" a little. So it does
not work on laptops.

The only real issue I had was that moving around is a little slow and awkward:
When going back and forth from C-f/b to C-p/n your hands are moving a lot. So
I remapped C-f to C-; and C-b to C-j (and similarly for M-f & M-b) and now I
can press Ctrl/Meta with my left hand and move around with my right one:
bliss.

~~~
ragnemalm
I can see that this might work with some keyboards, but I think the Apple one
is too low-profile.

Also, if you're not using C-M-... shortcuts, you're missing out:

C-M-{s,r} isearch-{forward/backward}-regexp (indispensable)

C-M-% query-replace-regexp (indispensable)

C-M-\ indent-region (indispensable for when M-q would mess up your line
breaks)

C-M-x eval-defun (for running changes to your .emacs without restarting)

C-M-q indent-pp-sexp (pretty-print and reindent sexp at point)

C-M-{f,b,u,d,a,e,k,t} forward/back/up/down/beginning/end/kill/transpose sexps

C-M-{n,p} {forward/backward}-list

C-M-v scroll-other-window

And so on. C-h k (describe-key) is your friend.

------
bprater
YOU know what would be really useful?

To have an expert Emacs user do a screencast of himself doing standard
programming stuff.

I think that would make it really obvious how these types of editors are.

~~~
wheels
Well, you'd need to have some way to do quick keyboard tracking with the
screencast. Just seeing all of the text get highlighted and re-indented
wouldn't do a lot. I'm not sure how much more it would help if you could see
that "[ctrl-x], [ctrl-h], [esc], x, indent-region" was typed...

~~~
capablanca
There's actually an extension by Michael Weber that might be helpfull for
recording screecasts:

<http://www.foldr.org/~michaelw/emacs/>

------
anotherjesse
I spent a couple hours every day doing the basics (first learning buffers,
then file stuff, then on and on...) within a week I had decided to switch from
VIM. (I used only emacs while on vacation for any editing I needed to do)

My suggestion - stop reading all the tutorials and just do it.

Keep a list next to your computer with 5 things you need to know how to do -
with the key strokes next to them.

Once you become comfortable create a new list that is what you need to learn
now. Don't over extend (ooh, git integration, org-mode, ...) - you'll get
there (and probably within a few weeks) - but focus on the basics first. Once
those become muscle memory you can figure out the advanced stuff.

~~~
silentbicycle
Also, first things first, Control-H followed by t brings up a tutorial. Work
through that, it covers all the basics.

~~~
silentbicycle
And after than (as jrockway noted elsewhere), press Control-H i to get to the
Info pages menu, which is the hypertext documentation inside Emacs. What
you're looking for is almost certainly in the main Emacs section or the Emacs
FAQ.

Info has its own manual, but most of what you need to know to start is that
Enter visits a hyperlink (which are probably purple and/or bold), 'u' goes up
one level, 'n' and 'p' go forward/backwards one node, and 's' searches. (To
get a more detailed keyboard shortcut list, type "Control-h m" inside of the
_info_ buffer.)

------
anamax
> A nice looking GUI and

You're editing text. What "graphical"s are you expecting? (You should be
seeing syntax and selection highlighting.)

> well designed intuitive interfaces matter to me.

What's the difference between "intuitive" and "familiar"?

Yes, the keyboard commands are not what you're used to. If you want the
keyboard commands that you're used to, you can program them. That's generally
a bad idea, but emacs is full of rope.

~~~
mechanical_fish
_If you want the keyboard commands that you're used to, you can program them.
That's generally a bad idea..._

Let me underline this sentence. Some people (particularly the ones who think
that _copy_ and _paste_ were invented by God on the eighth day of creation)
get it into their heads that they should redesign the emacs interface on their
first day. This is particularly tempting because the ability to remap keys all
over the place is one of emacs' best features.

Resist the temptation to do this at first. The emacs ecosystem actually makes
a great deal of sense once you settle into its way of thinking. It's sometimes
hard to believe, but very smart programmers have spent decades working out
where to put things in emacs. If you insist on ignoring their efforts, and
instead try to pretend that emacs is a lot like the Mac OS, you will never
even learn the basics, like the glories of the kill ring and the mark ring, or
the important distinctions between a file and a buffer.

~~~
silentbicycle
A couple reasons to not try to immediately make the keyboard shortcuts match
the editor you're used to:

* You'll probably overwrite some other really useful keyboard shortcuts unintentionally. C-v (Paste, on Windows) is page-down in Emacs. C-c is the prefix for mode-specific commands; C-c C-c sends email, compiles the function under the cursor, etc., depending on what file / buffer type you're working in.

* Emacs has its own ways to do some of those operations. Copying and pasting under Emacs is fundamentally different because of the "kill ring". Instead of having a clipboard, it has a stack (which loops once you hit the end, hence, "ring").

~~~
mindslight
> C-v (Paste, on Windows) is page-down in Emacs

I've tried to start using Emacs a few times now, and I just can't get this. My
keyboard already has page up/down and arrow keys that are accessible _without_
using a modifier. Why would I want to use a two key combo when a single key
will suffice? Page jumping especially is something that you're not going to be
in a rush to insert text afterwards.

The other thing I don't get is the ridiculous hand-mangling you've got to do
for the M-combos. (I'd already remapped caps lock to control)

I understand that many of its standard key combinations precede the keycaps
and de-facto standards of today, but I'd hardly consider it a loss for the
bindings to fit in better with the rest of a modern system.

I'm about to try Emacs for the third time. Are there any common sets of
alternative bindings?

~~~
silentbicycle
I find Emacs much easier to use with the Dvorak keyboard layout, but that's
its own big argument waiting to happen.

Under Qwerty, most of the common prefix keys (e.g. C-x, C-c, M-x) are
scrunched together on the left hand. If you're also using your left hand to
press Ctrl (whether on CapsLock or at the bottom left of the keyboard), you're
mangling your hand. That's why there's also a right Ctrl key.

FWIW, I sometimes use Page Up/Down and the arrow keys while just reading, but
tend to use the Emacs-style navigation shortcuts while actively editing. C-v
never made sense to me, either; I'm guessing it's just historical.

------
whacked_new
The learning curve is no joke. 2 weeks is nothing.

Don't get ambitious and treat it like your favorite editor just yet. Decide on
a small task with complexity (and hence requires you to jump back and forth
and rename stuff), like a 20-line script. Make plenty of use of the basic
keystrokes (C-f forward, C-b backward, C-p prev line, C-n next line, C-s
search, C-r reverse search). That's 6 combinations, and it's enough to witness
the kind of speed you have in navigating the text.

Then use it for a real editing job. Shouldn't take long before it becomes
second nature. Then, it shouldn't take long before you wished that every text
entry window used the same keystrokes.

Oh yeah, type return to complete the search.

------
wheels
All of the things that you list here are what Emacs is not. Above all, Emacs
is an investment -- not a two week investment, but one that you'll need a year
before it's really an extension of the way you code.

Here are some other additional notes:

\- You can get it on every platform. I personally use XEmacs (though I'd
recommend GNU Emacs for people starting now) and it's exactly the same on Mac,
Windows and Linux.

\- Many of the old Emacs die-hards learned Emacs in a time when Emacs had just
as good a GUI as anything else. So a lot of our rhetoric comes from an era
when _everything_ was driven by keyboard shortcuts. I do, however, believe
that learning how to use your editor from the keyboard alone does improve
long-term efficiency.

------
rgiar
In a word, emacs is responsive -- you realize this as you slowly become
familiar with the basic components: buffers and files, the point and region,
keymaps, ediff, ffap, running shells inside emacs, tramp, etc. and then, yes,
finally emacs lisp. Using these basic tools, you can mix, match and customize
until it does what you need for today's project, no matter what language or
OS,however many files, script languages, build tools, etc.

At some point it becomes clear that emacs is actually a programming
environment for text editing with emacs lisp in the position of universal
configuration, scripting and compute language. If you can think of something
you want to do with text,files or code (albeit limited to an ascii interface)
you can either find it in the extension community or you can quickly bend
emacs to do what you want.

My learning curve was approximately two years to feel very competent, five or
so to feel like a power user, and then 8 or so to feel make it do most
anything.

------
saurabh
I think you are looking for an editor which feels modern but has the power of
emacs,vim or textmate. If you are on Windows, you can try
<http://www.e-texteditor.com/>. If on OSX, <http://macromates.com/> Even i
used to go round this question. I tried emacs, then vim , then textmate, then
e-texteditor. Finally i felt Vim to be comfortable for me. You need to try all
of those before settling on one.

------
gz
I remember when, having coded in emacs for a few years, I used it for the
first time to do a 3-way merge on thousands of lines of code. The amount of
time and effort I saved astounded me. The point here is twofold:

1) emacs is very well integrated with extremely powerful tools (in this case
diff, merge)

2) emacs is deep; even as an advanced user you can keep improving your
efficiency (albeit at a lower rate)

Having said that, I have a question: once I had become fairly comfortable with
emacs I switched back to vi. I felt there was a positive correlation between
learning new keystrokes/tricks while coding and the quality of code I produce.
Has anyone else observed that? If yes, why do you think this is so?

~~~
Hutzpah
I am no coder, I use Emacs as my 'DTP package. But I can relate something rom
graphic design. Why a graphician should be able to draw stuff with pen and
paper rather than only work at the computer? Because the connection between
thought and hand is faster with pen and paper. Hence, broadband output and
feedback loop. Not just faster but enhaced quality: so fast that feedback loop
becomes subconscious, direct, flow. Maybe in programming with vi /emacs the
same thing occurs.

~~~
silentbicycle
Yes, particularly with good development modes (e.g. SLIME for common lisp,
Tuareg for OCaml), the feedback loop between the language runtime and the
editor is immediate.

------
abstractbill
At this point I've spent about ten years learning Emacs. I'm sure there's
still plenty I could learn that would make me even more productive - Emacs is
_big_.

When I was in my early twenties, I decided enough of my heroes at the time
raved about Emacs that I should just trust them and not care how long it took
to learn or how hard it was. This turned out to be a good decision.

~~~
mixmax
This is pretty much the reason I decided to give it more than the normal five
minutes of attention that shareware gets before a decision is made. A great
number of people that are way smarter than me think it's the best thing since
sliced bread. And by definition they can't be all that stupid :-)

------
pdrummond
I am a die hard vim user who has been learning Clojure recently and I have
learned a little Emacs along the way because everyone in the Lisp community
bangs on about it.

The funny thing is, every time I go to write some Clojure code - I want to
open a Vim session, but I am always strangely drawn to Emacs for some reason.

Recently, I decided to figure out what it was about Emacs that made me want to
use it so much over Vim. I soon realised it was all about being able to load a
REPL process in a window and interact with it on the fly.

I can run Emacs, open a Clojure source file, write a function then hit C-M-x
to send the function to the REPL to be evaluated. Also relevant is that
Clojure support in Emacs was available shortly after Clojure's release to the
public late in 200.

This is a very specific case (lisp-style interactive development) but it's why
I personally think Emacs is great and for me it has nothing to do with Emacs
text editing features! I will always prefer Vim for pure text editing power.

~~~
ivey
I installed Emacs to install SLIME so I could play around with Lisp. The REPL-
in-a-buffer is so phenomenally powerful that I immediately missed it in
TextMate when coding in Ruby. Thus began my descent into Emacs madness, and my
new favorite function, ruby-send-region-and-go

I was a vi guy for a _very_ long time, and I mocked the Emacs guys for "eight
megs and constantly swapping" and "Emacs claw" ... until I switched to
TextMate on the Mac, and realized how Emacs-inspired it is. It was actually
very easy to go from TextMate to Emacs.

Along the way, I got more productive in my shell. Did you know that M-left
moves back a word on the command line? I didn't, and I've been using bash for
10 years. Oh, and it works in all readline-enabled apps.

~~~
jimbokun
Did you know you can run a shell inside Emacs?

I get frustrated when running a shell in a regular terminal. They all
implement some subset of emacs editing keystrokes, but never all of them, and
the subsets are different. It's wonderful having all editing, searching, etc.
functionality of emacs available when typing in your shell.

I wrote some Emacs Lisp to jump to the line of a javac syntax error, or stack
trace line with a single keystroke. Combining that with the ability to run a
shell and browse log files comes in very handy. I also have a macro that
searches for the Java symbol under the cursor. It misses a bunch of edge
cases, but still very useful. All of this in just 55 lines of elisp. How many
lines does it take to write "Hello, World!" as an Eclipse plug in?

------
yason
I would say that someone who is effective at Emacs works just the opposite
way:

\- No mouse; \- No GUI; most people hide even the menu bar; \- They have spent
and do continue to spend a lot of time in Emacs.

Someone suggested a video recording of an Emacs session. That sounds like a
good idea!

------
coliveira
If you are trying to program in lisp, then Emacs is probably the best option,
since it follows the lisp way of doing things. For normal editing tasks,
however, I prefer vim.

------
dgreensp
I don't think emacs has a steep learning curve for being a really efficient
editor, the way (say) vi does. If you can get through the day in emacs without
touching the mouse, you're basically there, and the rest is just discovering
all the features and ways to customize it.

Force yourself to move the insertion point with the arrow keys, for starters.
Then learn a few shortcuts so you don't go insane. C-a for beginning of line,
C-e for end. M-f and M-b for forward/backwards by a whole word. C-v and M-v
will scroll you up and down through the document and move the insertion point
so that it stays on the screen.

Emacs doesn't need a lot of UI. It isn't an IDE, for one thing (though it can
be used as one). Customization is done by putting incantations in your .emacs
file. Managing buffers and panes only requires a handful of commands; learn
the keys for them, or re-assign them if they're awkward.

------
silentbicycle
If you prefer to use the mouse, rather than keyboard shortcuts, you might be
happier with something like Acme/Wily (<http://www.cse.yorku.ca/~oz/wily/>).
It's not available for all platforms, though.

Emacs is intrinsically a keyboard-driven editor, and mostly just tries to keep
the GUI out of the way. Your experience is more meaningful than anybody's
dogma about whether keyboard-centric or mouse-centric development is more
productive _for you_ , but mostly using the mouse will make it hard to take
advantage of what makes Emacs special.

(If you, or other readers, want to really learn Emacs, you should probably
give it at least a month. Once you're comfortable with the basics, gradually
learning elisp will greatly increase how useful it is for you.)

------
msg
I've been using for months. It took a while, and the O'Reilly book, Yegge's
post, and EmacsWiki were all extremely helpful (in that chronological order).
You might also consider just reading the manual too (although you might want
to hold off until you have more experience).

Another resource that will be really helpful somewhere in there is to just
type C-h C-h. You'll see a listing of various kinds of help. I use these a
lot, especially to explore something new:

C-h k (type any keyboard shortcut) "what does this shortcut do?"

C-h b "list all keyboard shortcuts from all modes in the current buffer"

C-h f (type a function name) "what does this function/command do?"

C-h v (type a variable name) "what does this variable do, and what is its
value?"

C-h a (type a regexp) "list all commands matching the regexp"

M-x apropos (type a regexp) "list commands, functions, variables, etc.
matching the regexp"

------
kylec
As a followup question, what is the best resource to most efficiently learn
the basics of Emacs?

~~~
silentbicycle
In Emacs, press Control-h, let go of Control, and press t. That starts the
tutorial, which will probably take about half an hour.

After working through that, some combination of reading the Emacs Wiki
(<http://www.emacswiki.org/cgi-bin/wiki>) and a recent edition of _Learning
Gnu Emacs_ will get you off to a good start.

Getting really effective with Emacs takes a while (probably at least a month),
but it is very deliberately designed to be _keep growing with you_. If you
come to prefer it for editing, you can bundle together your config files and
extensions and run Emacs on all the major OSs. It becomes its own extensible
environment, much like Firefox with its extensions. (This is why the time
spent learning it pays off.)

~~~
jrockway
_In Emacs, press Control-h, let go of Control, and press t. That starts the
tutorial, which will probably take about half an hour._

IMHO, the tutorial is useless. It spends too much time on C-p and C-n and not
enough time on anything useful.

I recommend reading the Info documentation. It is very well written and very
complete. You should also read the Elisp reference manual; having an
understanding of the internals is helpful even if you don't intend to program
emacs.

~~~
silentbicycle
I definitely agree about the Info documentation (I forgot to include that),
but I think the tutorial is still worth doing: it covers the extreme basics
_using Emacs's terminology_. It's hard to figure out how to do some things in
Emacs via the info pages (or apropos, emacswiki, etc.) without knowing that,
for example, each pane inside the Emacs window is called a "window" (Emacs
calls the main window(s) "frames").

Also, it covers some conceptual things upfront, like how C-f is forward-char
but M-f is forward-word, and that M-somekey is often a more abstract version
of C-somekey. (Also, how to read the "C-x M-c butterfly" style keyboard
shortcuts in the first place.) A lot of the things it covers ("C-x C-s is
save") are pretty basic, but it tries to introduce some of Emacs's
cultural/design quirks, which are probably what really trip up a lot of
people.

------
travisjeffery
I'd recommend reading "Writing Gnus Emacs Extensions" why is it the best,
obviously because it's one if not the most extensible piece of software ever
made. And it chose one of the best languages to implement it's extensibility.

------
dimitar
How about Easymacs? I dislike the standard shortcuts not because they are
difficult to remember, but because they cause me pain in my hands and I've
never had anything of this sort before. I've tried remapping the caps lock
key, but it didn't help much. Now I find that using Emacs is much more
enjoyable. I don't think torturing yourself is justified. I can spot only one
drawback: you have to take your fingers of the home row (learn touch typing,
my rodent-using friends) a bit more.

------
Flemlord
> Why is emacs a great editor?

It isn't--don't believe the hype. On the other hand, I couldn't write a line
of code without IntelliSense.

Does anybody know anything about Emacs.Net that Microsoft is working on?

[http://www.knowing.net/PermaLink,guid,31fdc849-db2a-4f7d-bf9...](http://www.knowing.net/PermaLink,guid,31fdc849-db2a-4f7d-bf96-44df005a06b4.aspx)

~~~
msg
In Emacs, etags plus dabbrev-expand plus tags-apropos equals Intellisense (or
close enough for shooting). A lot of Emacs' power comes from this Unixy
ability to string together tools to create something unexpected...

------
ricky_clarkson
I'd suggest using your mouse less - you can increase your speed more with the
keyboard than you can with the mouse.

There are a number of looks that emacs can have, from emacs -nw (runs in your
terminal emulator) to emacs with GTK. And there are colour themes within each.
M-x color-theme-select

------
Ben65
People love emacs because you can customize it to your liking. That's why it's
touted as such a divine tool, and that's why it's worth it to keep trying to
learn it.

------
globalrev
When I saw the light: <http://news.ycombinator.com/item?id=233172>

------
Hutzpah
Emacs has an intuitive interface - the keyboard shortcuts. Discover them.

