Skip to content

Instantly share code, notes, and snippets.

@quanticle
Last active June 24, 2021 18:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quanticle/88c96c8dda99766d81229666f72a3697 to your computer and use it in GitHub Desktop.
Save quanticle/88c96c8dda99766d81229666f72a3697 to your computer and use it in GitHub Desktop.
Org-mode Tips

Org Mode

  • To have org-mode expand everything by default: M-x customize-variable RET org-startup-folded

  • To insert code-blocks quickly: <s TAB

  • To insert a new bullet/number in the current list: M-RET

  • To promote a heading: M-<left arrow>

  • To demote a heading: M-<right arrow>

  • Hyperlinks:

    • To link to another org-mode file:

      [[file:dir/other_file.org]]
      
    • To create a link with a description:

      [[file:dir/other_file.org][Description]]
      
    • To follow a hyperlink C-c C-o

    • To go back: C-c &

    • To edit a link: C-c C-l

      • Link = link target
      • Description = description
  • To add LaTeX to Org-mode:

    • Don't need to do anything special to add LaTeX to org-mode
    • Use \( and \) as inline math delimiters
    • Use \begin{equation} and \end{equation} for blocks for equations
    • Can preview LaTeX with C-c C-x C-l if `dvipng` is installed
  • To escape markup:

    • Verbatim
    • Code
  • To export to HTML:

    • C-c C-e h h (to export to file)
    • C-c C-e h o to export to file and open
    • Export config options:
      • org-export-with-toc toggles TOC
      • org-export-with-section-numbers toggles section numbers
  • Generic markup:

    • /italics/ italics
    • _underline_ underline
    • *bold* bold
    • +strikethrough+ strikethrough
  • To set the initial visibility of an item, add the following property: :Visibility: folded

    • A property drawer starts with :PROPERTIES: and ends with :END:
    • To insert a property (and create the drawer, if necessary): C-c C-x p
    • To reset to initial visibility: C-u C-u
  • To add a single checkbox: C-u C-c C-c

  • To make a list into a list of checkboxes: C-u C-c C-x C-b

  • To make the to-do statistics cookies compute statistics recursively

    • Configure org-hierarchical-todo-statistics to set recursive stats globally
    • Set the :COOKIE_DATA: property to "recursive" to set it on a per item level
  • To override the default initial visibility, put one of

    #+STARTUP: overview
    #+STARTUP: content
    #+STARTUP: showall
    #+STARTUP: showeverything
    

    at the top of the file

    • To undo all visibility changes made while editing, C-u C-u <tab>
  • Table editing:

    • To create a table, start the line with a | and separate each column with |
    • To create a horizontal line, start the line with |- (this separates headers from entries)
    • To insert a row above: M-S-<down>
    • To insert a row below: C-u M-S-<down>
    • To delete the current row: M-S-up
  • Agenda mode

    • First, set up the following keybinds

      (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)
    • To launch agenda mode hit C-c a

    • To add files to the agenda list: C-c [

    • To remove a file from the agenda list: C-c ]

    • To launch the global to-do list: C-c a t

    • To go to the file in which a to-do item is defined

      • go to file in another window
      • go to file in this window
    • To rebuild agenda buffer: r

    • To set priorities on agenda items C-c ,

      • You can also adjust priorities with S-up and S-down
      • To adjust the values used for priorities, customize
        • org-highest-priority
        • org-lowest-priority
        • org-default-priority
      • To give priorities different colors:
        • Customize:
          • org-agenda-fontify-priorities -> set to "Cookies Only"
          • org-priority-faces -> set a color for each priority
        • My priority faces
          • 0: red2
          • 1: gold1
          • 2: SpringGreen2
          • 3: CadetBlue2
          • 4: gray94
          • 5: gray50
    • To customize how items are sorted in the agenda view mode, customize org-agenda-sorting-strategy

  • To turn bulleted list into a numbered list, use S-left or S-right to change the bullet style

  • To make the agenda view use am/pm times instead of 24-hour time, do M-x customize-variable RET org-agenda-timegrid-use-ampm

  • To disable plain-text timestamps, turn off org-agenda-search-headline-for-time

  • To prevent emacs from folding subtrees when you paste them, customize org-yank-folded-subtrees

  • To make emacs only color the stars in a headline, customize org-level-color-stars-only

  • To launch org-agenda in its own frame, customize org-agenda-window-setup

  • To delete org-mode-links, add the following function to your .emacs

    (defun afs/org-replace-link-by-link-description ()
    "Replace an org link by its description or by the link if description is empty"
    (interactive)
    (if (org-in-regexp org-bracket-link-regexp 1)
      (save-excursion
      (let ((remove (list (match-beginning 0) (match-end 0)))
          (description (if (match-end 3)
                  (org-match-string-no-properties 3)
                  (org-match-string-no-properties 1))))
        (apply 'delete-region remove)
        (insert description)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment