Wiki home > emacs.html
Please see also my (redacted) .emacs.d on github. (As an example of a redaction, I have org-capture templates for the people I commonly meet with to add agenda items for our upcoming meetings.)
What is Emacs?
Emacs is a text editor that's been around since at least the 1980s. Emacs is in many ways the exemplar of GNU software: it was designed to be totally open-source, where you could change anything yourself, much like how the VW Beetle was designed to be easy to maintain.
I was first introduced to Emacs in the mid-1990s when one of my friends told me "there's a text editor that will tell you the sunrise and sunset for the current day if you tell it your latitude and longitude." (This was a big deal prior to the Internet.) Then I learned that Emacs had Eliza the chatbot built-in. Then I learned it played Tower of Hanoi for arbitrary numbers of rings.
I didn't really start to use Emacs until college, when I switched to using FreeBSD as my primary operating system. Different types have tools are designed for different patterns: Windows machines are designed for Microsoft tools like MS Word; FreeBSD was designed to let you run open-source software.
By this point I was fairly deep into Unix systems administration work, both for my jobs/internships and as a Perl programmer. The two main editors at the time were
Emacs. I got really good at using vi. However, I wanted to learn more about Emacs. I think I really got into Emacs due to a computer science course that was taught in lisp. I found that (for me) using Emacs and LaTeX to write papers on FreeBSD was not appreciably harder than trying to use Microsoft-compatible tools.
Oh also Emacs is written in Emacs lisp, which is a lisp variant. Everything in Emacs can be controlled via Emacs lisp, including what Emacs does in response to any keystroke you hit. Emacs therefore has great lisp parsing capabilities, which is especially important for helping you wade through matching parentheses.
So I'd say over a period of around 20 years I've learned Emacs in fits and starts. Nowadays I'm actually using it for most types of writing, such as checking my email and creating this web site. My experience fits with the article, "Learn Emacs in Ten Years."
I enjoy learning different user interfaces and different ways of approaching work. Emacs is heavily keyboard-dependent and rewards people who invest time in learning to working more effectively. Here are a few things that Emacs can do that are, in my experience, difficult to do in other editing tools:
- Extensible, e.g. someone created a module emacs-google-this to let you search Google from Emacs.
- Customizable, e.g. I bound a key command to record a new to-do item. I can type this key command from anywhere in Emacs to record a new to-do item as well as record a link to wherever I am when I record the to-do item.
- Easy to navigate via the keyboard, e.g. there are key commands to go forward a letter, a word, a sentence, a paragraph, a screen, or more.
- Easy to "chain" commands, e.g. you can create a macro that goes to the beginning of a line, deletes the first word, then goes to the end of the line, adds a word, and then goes down to the next line. You can then run this command over every line.
- Many "modes" of domain knowledge for different types of content, e.g. there are many programming language-specific modes, "org-mode" for organizing text and to-do's, several email modes, version control modes, and more. Multiple modes can apply to the same content, e.g. if you are using markdown and also version control.
It's definitely possible to use "vanilla" Emacs, with no configuration. However, it's common for people to create a
~/.emacs file and then later move on to creating a whole
~/.emacs.d configuration directory. Emacs will read these configuration files to figure out what you want Emacs to do that's specific to you. You can see a redacted version of my
~/.emacs.d on github (borwick/emacs.d).
Here are a few things that I've configured Emacs to do. I've written the bulk of my Emacs configuration in a "literate programming" style, where there's text surrounding my configuration to explain it. You can see that via emacs.d/settings.org. As a few examples:
- Prompt me to make sure I really want to quit, when I tell Emacs to quit
- Turn on specific modes depending on the file extension, e.g.
- Create "capture templates" to let me record new to-dos or other items, and bind these to keyboard commands
Emacs uses an incredible number of keyboard shortcuts. It's so many that there's a keyboard shortcut to show you the currently-active keyboard shortcuts (
C-h b). Keyboard shortcuts are written as a list of keystrokes with modifier keys:
|Modifier||Emacs||Example||What this means|
What's "Meta"? Meta can be configured, but it's usually ALT on Windows, Option on OS X, and can also be accessed by hitting the Escape key. (For example
M-h could be typed as
ESC followed by
It's pretty safe to say that if you don't want to learn any keyboard shortcuts, you shouldn't use Emacs.
If you are up for learning keyboard shortcuts, then if you're doing something several times then you may find there's a keyboard shortcut that will help you. Here are a few that I use that are baked into Emacs. (I have added other custom keyboard commands too.)
|What I type||What it does|
||Capitalize this word|
||Lowercase this word|
||Go to beginning of line|
||Go to end of line|
||Replace whatever I pasted last with the previous clipboard content|
The commands start to end up like that last example, where if you're from another editing environment you might say, "huh?" In that particular example, Emacs has a thing called the "kill-ring" and it remembers the last many things that you cut or copied; then when you paste you can say "actually I meant the thing before that" with
If you are interested in using Emacs:
- Download Emacs
- Install Emacs
- Run Emacs
C-h t. (
C-hmeans "help" and
If you have run the tutorial, some next steps you can try are:
- editing a file that Emacs natively supports, which includes most programming language files and text files
- starting a writing project: choose the format you want to use/try:
- texinfo? (If this is the format you're going to use, you probably shouldn't be reading this page)
M-x customizeto customize Emacs
- creating a
~/.emacs.d/init.elfile to customize Emacs through code you write
- trying to add a little new functionality to your existing Emacs environment:
magitfor Git version control
- looking through
list-packagesto see other Emacs modules
- looking through other people's .emacs.d examples
- looking through the Emacs manual