Xah Lee, 2010-03-15, 2010-07-30
Emacs has a mode called outline-mode. A much improved version with better keyboard shortcuts and much more features, is called org-mode. This page shows you the basics of org-mode.
Sometimes you need to write some notes with a tree-structure. For example, headings, subsections, and content text. This is called outline format in word processors. You want to be able to view just the headings, or view all content of a section but hide the rest, etc.
In your file, any line that starts with a star * followed by space, is level 1 heading. Any line starting with 2 stars ** is level 2 heading. Here's a example file:
* to do Remember to bring lunch box and 2 bananas. ** call mom don't forget to call mom ** do that * call Jane. her phone is 123-4567 * finish coding absca. john was not happy. ** give that tutorial to john. ** Dave wanted do lunch. He got some ideas. * learn emacs outline stuff texts can actually be free form.
The star character must at the beginning of line, and must have a space after it.
Copy the above text in a file and save it. Now, open the file, type 【Alt+x org-mode】. Then, emacs will show it like this:
The following commands can be used to create headings.
Once you have written a lots text in a outline tree structure, you usually want to add or edit your notes in a way not to destroy the existing tree structure. The following commands are good for it.
If you name your file ending in “.org”, emacs will open it in org-mode automatically.
You can also put this line as the first line of the file:
-*- mode: org -*-
Emacs will start org-mode when the file is opened.
If you want any file ending in “.txt” open in org-mode, you can add this line to your emacs init file:
(add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))
org-mode is often used for todo notes too. org-mode has many features for todo. For example: date range, deadlines, scheduling/agenda, priorities marking, and integrated with emacs calendar, and diary, etc. Here are some basics in using org-mode for todo.
Some heading can be marked as a todo item. For org-mode to recognize a todo item, the word “TODO” (all caps) must happen as the first word in a heading. Like this:
** TODO call mom for bday.
org-mode has commands to help you change a heading to todo item. The TODO string might also be DONE. There are also commands to show only TODO headings.
<2010-07-31 Sat>.Timestamp can also have hour and minutes, or be a range. (info "(org) Timestamps")
Each heading may have a tag (aka keywords, label) associated with it, for later collection of related entries. For example, you can have items with tags such as “work”, “family”, “urgent”, “coding”, “study”, or any word you like.
The syntax for tag is any word between colon, like this: :something: or :this:that:. They are usually placed at end of the line. Like this:
** call mom for bday. :family:... * finish writing the org-mode tutorial. :emacs:work:
Tag names cannot contain space, but can contain numbers and “_” and “@”.
Tags are inherited from parent nodes, in the sense that when you search for a tag, a heading with that tag will show but also all its children, even if the children's headings do not contain that tag.
When in org-mode, there's a menu “Org”. Try it. I always forgot to use the menu. From the menu, you can learn the most useful commands, or remember the key shortcuts. There's also the menu 〖Org▸Documentation〗 that lets you easily goto org-mode's info doc.
org-mode also has a big website with tutorials, FAQ, and lots other tips and discussion forum, wiki, also a Google Techtalk video where the author Carsten Dominik speaks about it. Its home page is at: orgmode.org.