Update: Please take the content of this post with a grain of salt. I wrote this at a time I was easily impressed. I still think Emacs is great editor, but it is not the only one. Look around, do your own experiments and pick the editor that fits your needs best. Although I don’t like the evangelizing tone of this post, I still believe in its conclusion: mastering an editor is an extremely worthwhile investment if you are doing a lot text editing.
Here a few Emacs tips and some gospel for those who are still using a
butter-knife editor. First, the most important skill you must develop is touch typing. This
is what make the most difference in your productivity. I found out
that Emacs is really pleasant when you are able to type, at a rate
above 50WPM. One thing is sure, being able to type fast, make any
typing task more pleasant. From my own experience, when you get good
with the keyboard, you start spending less time reading about other
people achievements and start creating your own cool stuff. And
learning to type fast is easy. Find some online typing material and
spend 15 minutes per day, working on your typing skills. You will
never regret it.
Most IDE do a lot of code generation, because some programmers are too
lazy to learn touch typing. So, they need snippets, IntelliSense,
automated refactoring, etc. They’re all nice features. But, do they
really make you more productive? I don’t think point-and-click
programming is really productive. That is where Emacs comes in. Emacs,
and also Vim, are different in the way they attack the problem of
rapid development. They both try to make editing easier, and this is
a truly challenging task.
Emacs gives you the power to make your editor. Some people may
argues that, this feature made Emacs an operating system. Yet, it is
this flexibility that made Emacs so powerful. Almost all the commands
in Emacs are coded with Emacs Lisp — a full programming language
built in Emacs. Even the cursor behavior is coded in Emacs Lisp. How
many of these point-and-click IDE have you seen, which allowed you to
change how you move the cursor? I bet the number is near zero. An
example of this power, is a mode called chop
. This mode makes your
cursor behaves like a binary tree. It allows you to reach any line on
your screen in O(log2 n) steps, where ‘n’ is the screen’s height. In
plain English, this means you can reach any line, on a 130 lines
screen, in less than 7 keystrokes. However in reality, the number
steps is much smaller, because Emacs has a full set of other tools for
moving your cursor, where you want it.
Now the interesting part, how to get good with Emacs. Learning Emacs
is the same thing as learning touch typing. You need to practice a lot
and frequently. The first thing you need to master is the keyboard
shortcuts. There is a lot of shortcuts, in Emacs. There’s probably
more than your brain can hold. But with some training, we will see
that Emacs’ keyboard shortcuts are easy to remember. They all follow
the same structure. Like touch typing, there’s also tools for learning
the keyboard shortcuts. I highly recommend keywiz
, which run within
Emacs. This tool analyzes all the keyboard shortcut in Emacs, even the
one you changed, and generate quizzes about them. Again, same idea as
touch typing, practice about 15 minutes per day on a daily basis.
As your journey progresses, you will find the need to change some of
the default behaviors of Emacs. This is done by putting stuff in your
.emacs
— the most precious file of any Emacs user. Trust me, you
don’t want to lose this file. So, make sure you do regular backups or
use a version control system, like Subversion, to protect it. How to
use this file is an art itself. Some people like to keep all their
configuration in a single file, some don’t; some others don’t care if
it’s messy, some don’t; and so on. Personally, I like to separate the
different components into smaller files. And, I like to use
customize
for the on/off type of settings. But, that is just
question of personal taste. There isn’t a better .emacs
. The best
one will always be yours. You will, although, want to see how the
others configured their Emacs. That is normal. We are all curious
creatures, after all. A final note about .emacs
, don’t spend too
much time playing on it. Configuring Emacs is fun and addictive, but
it won’t help your productivity by much, if you can’t touch type or
use the keyboard shortcuts.
The last, but not the least, thing you need to know, is Emacs Lisp.
This is probably… No, this is the greatest feature of Emacs. And,
it’s also the hardest to master. Learning a programming language is
not the same thing as learning touch typing. Dumb practice won’t help
you. You will need to sit down and think. Lisp, and all its
parenthesizes, freak most people, who got some programming
experience. Unlike some people says, Lisp is easy to learn. There’s
nothing exceptional about learning Lisp. You learn it as any other
programming language. Get a book, read it attentively, write some
code, repeat. That’s my general algorithm for learning programming
languages, and it works. I learned several programming languages,
including Lisp, this way. One more thing, knowing Lisp do not make you
a superior programmer. What makes you a superior programmer is your
ability to learn new ideas. So, don’t get caught by this lie from Lisp
evangelists.
Emacs is still a great tool, even if you don’t learn Emacs Lisp. In
fact, many Emacs users never learn it and are still more productive
than the majority of the other editors users. You can always
copy-and-paste some Emacs Lisp code found on the web.
However, I haven’t said yet why you should learn Emacs Lisp. The
reason is that if you know it, you can add features to your editor,
on-the-fly, without even restarting Emacs. Did ever wished your editor
had a particular feature? Well with Emacs, when you know Emacs Lisp,
you just add it. Emacs evolves with you. So, if you do a lot of
programming, you will end with a lot of programming helpers and
macros. On the other hand, if you write a lot of web articles, you
will probably end up with a lot of text manipulation utilities. It is
just beautiful, how Emacs can adapt to your editing needs.
Finally, mastering a good editor is a lifetime investment. You better
choose one that can evolve with you or you will end up using many
different editors poorly. Remember, that being productive isn’t that
important, but the fun of mastering something is. You will smile when
you will transform a painful editing task into a trivial one. So,
enjoy your journey in the world of Emacs.