Org mode has been integerated with Emacs since version 22.2 and XEmacs since version 22.1. This short guide helps you get up and running quickly using Emacs and the Org mode.
Compared to many other programs, you need to know more to use Emacs well. In Emacs, you have to use a lot of shortcuts. While frustrating at first, you’ll soon find that you’re able to do more with fewer mouse clicks.
Everything, from opening a file to saving it, can be done with a mouse and a few clicks of the menus. As time goes on, however, you’ll learn that shortcuts and hands-free typing are the ways to go.
Because of its heavy reliance on double shortcuts, Emacs leverages the Control-X Control-F and Control-X Control-S instead of the more conventional Alt-F and Alt-S. This may seem counterintuitive at first, but you’ll quickly adapt.
Let’s see some of the key abbreviations or conventions that we will use when working with EMACS:
- M – Alt (That’s because in the good old days of mechanical keyboards, it was referred to as Meta.)
- C – Control Key or simply “Ctrl”
- S – Shift
- C-x f – This means to press and hold control and x. Then, let go of both and press f.
Installing Emacs on Debian/Ubuntu
Installing Emacs in Ubuntu is just a matter of typing a command:
However simple the installation, the major tasks are configuring and learning to work with EMACS. There is a config file that we need to edit. On the Linux systems, the location of this file is ~/.emacs.
Hands-On with Org Mode
Now that we have Emacs on board, let’s start working with it. For now, let’s focus on the following shortcuts:
- C-x C-s – To save the document
- C-x C-f – To open the document
Let’s start EMACS and open a new document with C-x C-f, and name it “demo1.txt”. A new blank pane will now appear.
By now, Emacs has no idea that you’re working on an Org file. It labels it as a text file:
Let’s enable the Org mode for our “demo1.txt” file by pressing M-x(Alt – x) and then entering the org-mode, as shown in the following:
The label on the bottom should now display (Org):
However, the next time you reopen this file, it displays it as text file again:
Now, to let Emacs always handle it as an Org document, type “-*- mode: org -*-‘” at the start of the document:
Notably, this sets the Org mode for this document, regardless of the file extension. Let’s save our file by pressing C-x C-s and reopen it:
Now, as you can see, the file is automatically opened in Org mode.
In the next section, we will show you how to modify your Emacs configuration so that the Org-mode will always be available for use with the “.org” files.
Configuring EMACS for ORG Mode
Open the emacs configuration file, “.emacs”. You can open it using Emacs itself by entering the C-x C-f or any other editor. Now, put the following content inside it:
;; Disable the splash screen (to enable it again, replace the t with 0)
(setq inhibit-splash-screen t)
;; Enable transient mark mode
;;;;Org mode configuration
;; Enable Org mode
;; Make Org mode work with files ending in .org
;; (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
;; The above is the default in recent emacsen
Note:The C-x C-f key combination activates the find-file feature which may be used to create a new document or access a previously saved one.
Finally, restart Emacs to activate the Org mode for all “.org” files.
Getting Started with the Org Mode
So far, we configured Emacs to work with Org type documents. Now, we can put it to use. First, let’s see the outline. The use of an outline is a great way to organize your ideas when making notes or writing your work.
An in-built feature of Emacs is the outline-mode. We can use it to organize the text into individual entries. Each entry consists of a headline and a body. Furthermore, these entries can be nested to build a tree-like structure of hierarchical information.
Adding an Introductory Section
Create a new text file (C-x b), save it as “demo2.org”, and enter some contents into it. Let’s start by adding a title line, suing the #+title tag:
We don’t need to add the “-*- mode: org -*-“ here since we already modified the Emacs config file. The meaning of the tag -*- mode: org -*- is already discussed. Now, let’s add the name of the author using the tag #+author:
Similarly, we use the #+date tag to add a date here:
Working with Headings
Now, let’s put some headings here. To accomplish this, we need to use one or more asterisks.
** This is a /italic/ Sub-Heading*
Notably, we can also modify the text with *bold*, /italic/, _underlined_, or =verbatim=.
If a line does not start with a star, it is taken as the content of the headline above it. Let’s add some text to our previous headings:
This is a plain text content.
This is another plain text content.
In this example, the “This is a heading” line is a body text for the “Heading 1”. Similarly, “This is a sub-heading” is a body text for “Sub-Heading”.
Note that “Heading 1” is the tree and the subsequent sub-headings are its branches. We can fold the branches and the body around a tree to hide it from direct view.
Also, we can expand a heading by putting the cursor on a heading and entering a TAB key or Shift-Tab.
Playing Around with the List
Let’s do some listing now. Making lists is an excellent way to organize your thoughts and stay organized. In addition, this kind of note-taking aids in maintaining a broad view.
Oftentimes, we need to insert a simple unordered list into the content of a sub-tree which is not an element/node of the document’s tree structure itself. For this, we can simply begin a line with a minus sign (-) or plus sign (+):
- First Unordered List Element.
- Second Unordered List Element:
+ First Unordered List Sub-Element.
+ Second Unordered List Sub-Element.
Use M-Return to insert the next list item. Org-mode automatically appends a – or + at the start of the succeeding list items.
Let’s move on to the ordered list. Starting a line with a “1.” or “1)” creates an ordered list; pressing M-Return inserts the next item and causes the Org-mode to automatically number the items in the list:
1. First Ordered List
2. Second Ordered List
- First Unordered Element in List.
- Second Unordered List Element in List:
1) First ordered element inside an Unordered List.
2) Second ordered element inside an Unordered List.
Just like the unordered list, use M-Return to have the Org-mode automatically number each consecutive item in the list.
What About the Hyperlinks?
Well, we can also add the clickable links in the Org mode. We can simply put links as usual:
Finally, our “demo2.org” file looks something like this:
It’s no surprise that describing all of Org’s features—including those for authoring, analyzing, and linking the chunks of source code in a document—can be a demanding effort. In this article, we just scratched the surface of what you can do with it.