Emacs Org mode gives you a complete interface for interacting with your systems. Whether you have a fleet of servers, or you’re a freelance web designer with a small cluster of clients, Org mode can help you keep track of your work while in the normal course of your daily activities. It is a unique productivity tool that may surprise you.
Before starting up with Org mode there are a few key commands you should go ahead and set in your Emacs init file first. These key commands may seem opaque to you now, but they will make sense later:
(global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-ca" 'org-agenda) (global-set-key "\C-cc" 'org-capture) (global-set-key "\C-cb" 'org-switchb)
Now you will be able to take advantage of these key commands when the time comes.
Org Mode Markup
Org mode is not only an organizational tool but also provides single source authoring functionality. This means you can write a document in Org mode markup and export it to virtually any format. All you need to do is familiarize yourself with this markup.
Hierarchical headings use an asterisk (
*). Level 1 headings use one asterisk, and each level beneath simply adds one asterisk.
* Heading Level 1 ** Heading Level 2 *** Heading Level 3 (And so forth.)
Likewise, you can use text decoration with forward slashes for italics (
/) and inline asterisks for bold text (
You can also nest content within quote and verse constructs using this markup:
#+begin_quote "I already know Unix." ---Dilbert #+end_quote #+begin_verse We shall not cease from exploration And the end of all our exploring Will be to arrive where we started And know the place for the first time. ---T.S. Eliot, /Four Quartets/ #+end_verse
But what’s the difference between quotes and verses? That depends on which export “backend” you choose. In HTML and LaTex, for example, quotes will ignore line breaks while verse will retain them. It’s important to remember that when using these constructs in plain text markup they merely indicate difference. How that difference is treated on the backend will be different in certain cases.
Also note, in most export backends the triples hyphens (
---) will be converted into em dashes (—). But this, again, depends on which backend you choose.
Here are a few backends that come pre-loaded with Org mode:
For a complete rundown of markup options please visit the Org mode documentation.
You might be wondering, “Why would I need to bother with document formatting?” Even if you’re not a writer, Org mode provides documentation features that lend themselves easily to literate programming. Literate programming, basically, means embedding snippets of code—or entire programs—within a written document.
Imagine how far you could extend this functionality. Let’s say you have a complicated set of shell scripts that complete all of your server maintenance for you. You can host these scripts in GitHub with a few comments interspersed, or you could provide fully articulated documentation around the scripts themselves, optimized for human reading. And, even more, these scripts could be run from within the document itself (provided your reader is using Emacs.)
To create a code snippet in your document type
C-c C-, and choose
[s] for source code block.
For example, here is a snippet of Emacs Lisp code that will run in your file itself:
#+begin_src elisp (+ 2 2) #+end_src
This particular sample, when executed, will add 2 and 2 and produce a result of 4.
Server Access and Hyperlinking Remote Files
One of the main benefits of using Emacs includes opening and (optionally) bookmarking remote files via SSH. Add Org mode, and you can actually hyperlink remote files, opening the connection and the file for editing with one click.
First off, once you have accessed a file with TRAMP, all you need to do is type
C-c l to store the link to that file. Then, open any Org document, highlight the text you want to hyperlink and type
C-c C-l, type or paste the URL in the minibuffer, and press return (or, enter).
Now, all you need to do to access that remote file is click the hyperlink.
Todo Items and States
With Org mode, you can set various headings in your document to various states of progress or completion. The default states are “TODO” and “DONE.”
You can also schedule items (for when you want to start working on them) or set a deadline (for when when you must complete something).
Remember, these states all work upon plain text files. So you can type them in yourself, or you can use key commands to set them.
- To schedule an item, place your cursor over the heading and type
- To set a deadline, type
In either case you will be prompted with a calendar. Select your date and press Enter. (If you want move forward or backward in the calendar press
#+title: Next Actions #+seq_todo: TODO WAITING | DONE * TODO Rotate passwords SCHEDULED: <2021-02-16 Tue> * DONE Write backup script CLOSED: [2021-02-16 Tue 11:42] SCHEDULED: <2021-02-13 Sat> * TODO Turn in quarterly usage report DEADLINE: <2021-02-19 Fri>
To cycle through todo states, you can use your Shift plus arrow keys for left right. Right moves forward by todo state while left moves backward.
As you can imagine, sorting through the various items listed in your files can get daunting after you add more content. This is where the agenda views come to the rescue.
The Org agenda collects data—from a list of Org files which you specify—and collects all the todo items, scheduled and deadline information, into one view.
To add an org file to the agenda list just type
Then, using the key command you added at the beginning, type
C-c a to bring up the agenda dispatcher. Use the keys listed to select which agenda view you would like to see.
This is the beginning of your journey with Org mode. From here, you have everything you need to get started.
- Visibility cycling
- fold various heading in your document open and closed to more easily navigate through
- Capture templates
- create templates for capturing new headings (or, nodes) into various Org files in your configuration
- File export
- expand the various export options in the dispatcher (
C-c C-e) to export your Org document into various formats
- File inclusion and setup files
- If there are any org structures you use frequently, you can put them in a reproducible “setup” file; likewise, you can dynamically include the contents of other files within a document
- File attachments
- Break free of the file system by attaching various files to one node within an org document
And be sure to check out other Emacs related content in the support center: