Org Mode Cheat Sheet

Table of Contents

Commands

  • `Ctrl-C Ctrl-T` - Move TODO through phases
  • `M-shift-R` - Add new bullet point or TODO
  • `Ctrl-c Ctrl-e h` - Convert to simple HTML
  • `Meta-x org-publish-project <RET>` - Create full site
  • `Ctrl-c Ctrl-d` - Set a deadline
  • `Ctrl-c Ctrl-c` - Add a tag
  • `Ctrl-c a t` - Show global TODO list
  • `Ctrl-c a a` - Show this week's agenda
  • `Ctrl-c a M` - Filter based on tags
  • `Ctrl-c Ctrl-l` - Create a new link or edit an existing one

Formatting

Headers

Text

  • Inline preformatted: `=foo=`
  • Bold: `-foo-`

Vimwiki Conversion Tips

== Converting Links =

  • Find: `\[\[\([a-zA-Z]+\)|\([a-zA-Z /]+\)\]\]`
  • Replace: `\2`

Converting Inline Images

  • -Find-: `{{local:\(.-\)}}`
  • -Replace-: `\1`

Preformateed Text

Part 1:

  • -Find-: `#+BEGINEXAMPLE
  • -Replace-: `-+BEGINEXAMPLE`

Part 2:

  • -Find-: `^#+ENDEXAMPLE
  • -Replace-: `-+ENDEXAMPLE`

Headings

Please note that in my case I'm converting each heading in vimwiki to a heading that is one higher in org.

  • H2
    • Find: `^==\ \(.-\)\ ==$`
    • Replace: `- \1`
  • H3
    • Find: `^===\ \(.-\)\ ===$`
    • Replace: `– \1`
  • H4
    • Find: `^====\ \(.-\)\ ====$`
    • Replace: `— \1`
  • H5
    • Find: `^=====\ \(.-\)\ =====$`
    • Replace: `-— \1`

Inline Preformatted Text

  • Find: \(.-\)
  • Replace: `=\1=`

Bullets

Non-task list bullets
  • Level 1
    • Find: `\-\ `
    • Replace: `- `
  • Level 2
    • TODO
Task List Bullets

Please note that none of these regex's records the status of the task.

  • Level 1
    • Find: `\-\ \[.-]\ \(.-\)$`
    • Replace: `– TODO \1 [%]`
  • Level 2
    • Find: `\ \ \ \ ­\ \[.-]\ \(.-\)$`
    • Replace: `— TODO \1`
  • Level 3
    • Find: `\ \ \ \ \ \ \ \ ­\ \[.-]\ \(.-\)$`
    • Replace: `-— TODO \1`
  • Level 4
    • Find: `\ \ \ \ \ \ \ \ \ \ \ \ ­\ \[.-]\ \(.-\)$`
    • Replace: `–— TODO \1`
  • Level 5
    • Find: `\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ­\ \[.-]\ \(.-\)$`
    • Replace: `—— TODO \1`
Links From Vimwiki To Org

Here's an example:

- [[../org_html/TimeAndForecastingNotes|Time And Forecasting Notes]]

Folding / Filtering

Only show the current section (org-narrow-to-subtree):

  • C-x n s

Show the entire document again (widen):

  • C-x n w

Recurring Tasks

Do something every Friday, and it must be done every Friday

--- TODO Take out trash
    SCHEDULED: <2015-03-27 Fri +1w>

Do something every X days and always create new tasks in the future:

--- TODO Read email
    SCHEDULED: <2015-03-27 Fri .+1d>

If I don’t complete the task until Monday then the next instance of the scheduled task will be on Tuesday.

org-agenda

org-agenda-files

If you want to set the `org-agenda-files` variable to a folder then add this to your `.emacs` file:

(setq org-agenda-files (file-expand-wildcards "~/gtd/org/-.org"))

The following section of the FAQ is also very helpful:

Please note that this variable is -not- updated after adding new org files until your re-evaluate the `.emacs` buffer. To get around that I replaced the line above with this:

;;; Agenda files

(defun set-org-agenda-files ()
  (interactive)
  (setq org-agenda-files (file-expand-wildcards "c:/td/gtd/org/-.org")))

(set-org-agenda-files)

; Bind this to a key so that you can rebuild this file list when you add new files.
(global-set-key (kbd "<f4>") 'set-org-agenda-files)

Now after adding a new org file with tasks in it I can just press `F4` and it will show up in my agenda.

Viewing Completed Tasks

To view all of the tasks that you completed in your agenda view do the following:

(setq org-log-done 'time) ; this wasn’t necessary for me
; In the agenda view, type the l button

org-capture

org-capture templates

This tip helps with org-capture. You can’t add tags to a todo if it’s added using org-capture because the C-c C-c shortcut is remapped to close the window. To fix this, you need to use the %g template entry. Here’s an example:

(setq org-capture-templates
    '(("t" "Todo" entry (file+headline (concat org-directory "/inbox.org") "Open Tasks") "-- TODO %? %^g")

Thes %g entry will prompt the user for tags.

Links

Opening Links In The Same Frame

This feels much saner to me than the default, which is to open org-related links in a different frame.

; http://stackoverflow.com/a/13075322
(setq org-link-frame-setup (quote ((vm . vm-visit-folder-other-frame)
               (vm-imap . vm-visit-imap-folder-other-frame)
               (gnus . org-gnus-no-new-news)
               (file . find-file)
               (wl . wl-other-frame))))

Intallation

On debian, installation is as easy as this:

$ sudo apt-get install org-mode

That's all you have to do. Once you're done with that command you can start editing Org file.

Publishing

General

Use `C-x C-w` to convert your org-mode agenda into lots of different formats. Save the file with an html extension to choose HTML. This also requires the htmlify.el file.

Adding Custom HTML ID Values To Headings

Simply add the following property drawer to your heading:

:PROPERTIES:
:CUSTOM_ID: Your Section Name
:END

Drawers

Property Drawers

Commands

To add a property to a property drawer (or create one in the first place):

  • C-c C-x p

Common properties

  • CUSTOM_ID
    • Assigns a custom HTML id to a heading.

LOGBOOK Drawers

This is where clock times are stored by default.

Commands

To add a custom note to your logbook:

  • C-c C-z

Src Blocks

Capturing STDERR

I stole this from http://kitchingroup.cheme.cmu.edu/blog/2015/01/04/Redirecting-stderr-in-org-mode-shell-blocks/.

Simply wrap your code like so:

exec 2>&1

echo "testing stdout" >&1
echo "testing stderr" >&2
date -g

:

…and here's what you get:

testing stdout
testing stderr
date: invalid option -- 'g'
Try 'date --help' for more information.

Upgrading

The easiest way to keep from running two concurrent versions of Emacs is to install the newer version from source in the global directory. This tells you how to do that:

Basically, it's a make, make autoloads, sudo make install after changing the following vars in the org-mode local.mk file:

# lispdir= $(prefix)/emacs/site-lisp/org
lispdir= $(prefix)/emacs/24.5/lisp/org
...
# datadir = $(prefix)/emacs/etc/org
datadir = $(prefix)/emacs/24.5/etc/org

Last Updated .