Writing Outline with Emacs (org mode tutorial)

Perm url with updates: http://xahlee.org/emacs/emacs_outline.html

Writing Outline with Emacs (org mode tutorial)

Xah Lee, 2010-03-15, 2010-07-30

This page is a tutorial, showing you how to use emacs to write document or notes with tree structure.

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 top level headings, or up to 3rd level headings, or view all content of a particular section, or hide a section.

In emacs 22 and 23, there's a mode called outline-mode and org-mode. org-mode is a major improvement of outline-mode, and provide much more features. Both uses the same plain text format.

This page shows you the basics of org-mode.

Star * for Heading

In your file, any line that starts with a star “*” is considered level 1 heading. Any line starting with 2 stars “**” is level 2 heading. And so on. 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 cell 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.

Copy the above text in a file and save it. (emacs_outline_sample_file.txt) Now, open the file, type “Alt+x org-mode”. Then, emacs will show it like this:

emacs outline mode screenshot

Show/Hide Levels and Sections

  • Type “Tab” to show/hide the heading the cursor is on. Type it again to cycle show/hide its subsections.
  • Type “Shift+Tab” to cycle the level of headings to show/hide for the whole file.

Heading Creation and Editing

The following are good for initial creation.

  • Alt+Enter” to creat a new heading at the cursor position. (it types the stars for you)
  • Alt+” and “Alt+” moves a heading up or down one level. (cursor must be on the heading)

Tree Branch Manipulation

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.

  • Ctrl+Enter”. Insert a new heading. (at the end of the current branch.)
  • Alt+Shift+” and “Alt+Shift+”. Move branch up/down but keep in same level.
  • Alt+Shift+” and “Alt+Shift+”. Move branch up/down a level.

Open Files In Org Mode Automatically

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 open the file with org mode automatically.

If you want all your “.txt” files open in org mode, you can add this line to your emacs init file:

(add-to-list 'auto-mode-alist '("\\.txt\\'" . org-mode))

Learn More

When in org mode, there's a menu “Org”. Try it.

Type “Ctrl+h m” while in org mode, then you can get a summary of all its keyboard shortcuts.

Org mode has a info doc manual too. Type “Ctrl+h i” to bring up info. Then, go down and click “Org Mode”.

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: http://orgmode.org/.

(info "(org) Top")

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs