Skip to content

Latest commit

 

History

History
1303 lines (1005 loc) · 51.6 KB

orgnowledge.org

File metadata and controls

1303 lines (1005 loc) · 51.6 KB

README #modemap

Majority of this info can be found also in spc h i -> Org Mode

General doom kbds

Sources: pragmaticemacs

  • M-H/L - promote / demote subtree
  • m-h/l/k/j - move line / object / anything {direction}
  • z o/c - org/open(close)-fold

SPC m , (org-switchb) - Switch between Org buffers.

SPC m / / SPC m g G - counsel-org-goto-all

Other kdbs:

  • SPC m e - org-export-dispatch
  • SPC m g i - org-id-goto
  • C-c C-x ! org-reload
  • SPC n S - Jump to an Org headline in ‘org-agenda-files’.
  • C-c C-c (when in the beg. of the .org buffer) - refresh local setup

Document Structure #docs

Initial visibility

When Emacs first visits an Org file, the global state is set to showeverything. This can be configured through the variable org-startup-folded, or on a per-file basis by adding one of the following lines anywhere in the buffer:

Possible #+STARTUP values:

  • overview
  • content
  • showall
  • show2levels / show3levels / show4levels / show5levels
  • showeverything

Furthermore, any entries with a ‘VISIBILITY’ property (see Properties and Columns) get their visibility adapted accordingly. Allowed values for this property are ‘folded’, ‘children’, ‘content’, and ‘all’.

Motion

SPC m . / SPC m g g - Jump to an Org heading.

  • g H - evil-org-top
  • g h - org-up-element
  • g k/j - org-backward(forward)-element
  • g s h - org/goto-visible heading with avy
  • SPC m g v - org/goto-visible

With [ / ] prefix:

  • c - org-babel-previous(next)-src-block
  • l - org-previous(next)-link
  • h - org-backward(forward)-heading-same-level

Structure Editing

  • C-RET / C-S-RET - insert new heading below / above same level and enter insert mode
  • M-RET - insert new heading same level and remain in normal mode
  • C-M-RET org-insert-subheading
  • M-S-RET - Insert a new TODO heading with the same level
  • M-h/l - promote / demote heading

Tree/subtree prefix SPC m s

  • h - promote subtree
  • l - demote subtree
  • k - move subtree up
  • j - move subtree down
  • d - cut subtree
  • r - refile subtree (instead of copy / paste commands)
  • S - sort same-level entries
  • n - narrow to subtree
  • N - widen (to remove narrowing)

SPC m */h - toggle heading (heading -> text / text -> heading)

Sparse Trees

Construct sparse trees for selected information in an outline tree, so that the entire document is folded as much as possible, but the selected information is made visible along with the headline structure above it.

SPC m s s / C-c / (org-sparse-tree) - Create a sparse tree, prompt for the details. To get back to normal tree view - 2x S-TAB.

The syntax for the search string is described in Matching tags and properties.

Lists

  • Unordered list items start with ‘-’, ‘+’, or ‘*’ as bullets.
  • Ordered list items start with a numeral followed by either a period or a right parenthesis, such as ‘1.’
  • Description list items are unordered list items, and contain the separator ‘::’ to distinguish the description term from the description.

To update type of a list or just rerender it cuz u changed anything - C-c C-c

SPC m i - org-toggle-item

Lists have same kbds as headers (for creating new / de/pro-moting..)

  • TAB on item to hide it just like normal heading:
    • nested entry
  • C-S-h/l (org-shift[direction]) - change bullet style

C-c ^ - Sort the plain list. Prompt for the sorting method: numerically, alphabetically, by time, or by custom function.

Drawers

Sometimes you want to keep information associated with an entry, but you normally do not want to see it. For this, Org mode has drawers. They can contain anything but a headline and another drawer.

C-c C-x d - insert drawer at point. With an active region, this command puts the region inside the drawer.

This text is inside the drawer

With a prefix argument, this command calls org-insert-property-drawer, which creates a ‘PROPERTIES’ drawer right below the current headline. Org mode uses this special drawer for storing properties (see Properties and Columns). You cannot use it for anything else.

You can also arrange for state change notes (see Tracking TODO state changes) and clock times (see Clocking Work Time) to be stored in a ‘LOGBOOK’ drawer. If you want to store a quick note there, in a similar way to state changes, use:

C-c C-z - Add a time-stamped note to the ‘LOGBOOK’ drawer.

Blocks

Org mode uses ‘#+BEGIN’ … ‘#+END’ blocks for various purposes from including source code examples (see Literal Examples) to capturing time logging information (see Clocking Work Time).

You can also get all blocks folded at startup by configuring the variable org-hide-block-startup or on a per-file basis by using

#+STARTUP: (no)hideblocks

Hyperlinks #docs

Open links just with RET

SPC m l prefix:

  • l org-insert-link
  • c org-cliplink - Takes a URL from the clipboard and inserts an org-mode link with the title of a page found by the URL into the current buffer
  • L org-insert-all-links
  • S org-insert-last-stored-link
  • i org-id-store-link
  • s org-store-link
  • d +org/remove-link (at point)
  • t org-toggle-link-display

spc n l (org-store-link) - store link (If the headline has a ‘CUSTOM_ID’ property, store a link to this custom ID) to be able to choose it later from the spc m l l popup menu

org-link-file-path-type - relativeness of a link (useful sometimes as a file-only var)

Internal Links

A link that does not look like a URL—i.e., does not start with a known scheme or a file name—refers to the current document.

Org provides several refinements to internal navigation within a document. Most
notably, a construct like ‘[[#my-custom-id]]’ specifically targets the entry
with the ‘CUSTOM_ID’ property set to ‘my-custom-id’. Also, an internal link
looking like ‘[[*Some section]]’ points to a headline with the name ‘Some
section’

When the link does not belong to any of the cases above, Org looks for a dedicated target: the same string in double angular brackets, like ‘<<My Target>>’.

[[my target]] - link to 'my target' above

If no dedicated target exists, the link will then try to match the exact name of an element within the buffer. Naming is done with the #+NAME keyword:

content here

[[some name]] - link to content with #id

During export, internal links are used to mark objects and assign them a number. Marked objects are then referenced by links pointing to them. In particular, links without a description appear as the number assigned to the marked object26. In the following excerpt from an Org buffer

  1. one item
  2. <<target>>another item

Here we refer to item target.

The last sentence will appear as ‘Here we refer to item 2’ when exported.

Radio Targets

Org can automatically turn any occurrences of certain target names in normal text into a link. So without explicitly creating a link, the text connects to the target radioing its position. Radio targets are enclosed by triple angular brackets. For example, a target ‘<<<My Target>>>’ causes each occurrence of ‘my target’ in normal text to become activated as a link. The Org file is scanned automatically for radio targets only when the file is first loaded into Emacs. To update the target list during editing, press C-c C-c with point on or at a target.

External Links

Just some examples (there r much more types of external links in org):

spc m l l -> file: -> link to a file

Elisp link (any elisp code or available emacs command):

[[elisp:org-agenda][My org agenda]]

Search Options in File Links

[[file:~/code/main.c::255]] - jump to line 255
[[file:~/xx.org::My Target]] - Search for a link target ‘<<My Target>>’
[[file:~/xx.org::*My Target]] - restrict search to headlines
[[file:~/xx.org::#my-custom-id]] - link to heading with 'CUSTOM_ID' prop.
[[file:~/xx.org::/regexp/]]

/TODO Items #docs

Basic TODO functionality

  • SPC m t (org-todo) - display all statuses possible
  • C-S-h/l/k/j (org-shift[direction]) - change heading status / priority
  • SPC m T / SPC n t (org-todo-list) - show the global TODO list
  • <M-S-return> (org-insert-todo-heading)

/TODO Extensions

Setting up keywords for individual files:

#+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
#+TYP_TODO: Fred Sara Lucy Mike | DONE

or a setup for using several sets in parallel:

#+TODO: TODO(t) | DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+TODO: | CANCELED(c)

/TODO Dependencies

If an entry has a property ‘ORDERED’, each of its TODO children is blocked until all earlier siblings are marked as done. Here is an example:

* Parent
:PROPERTIES:
:ORDERED:  t
:END:
** TODO a
** TODO b, needs to wait for (a)
** TODO c, needs to wait for (a) and (b)

You can ensure an entry is never blocked by using the ‘NOBLOCKING’ property

Progress Logging

Closing items:

The most basic automatic logging is to keep track of when a certain TODO item was marked as done: (setq org-log-done 'time)

If you want to record a note along with the timestamp: (setq org-log-done 'note)

The corresponding in-buffer settings are: ‘#+STARTUP: logdone’ & ‘#+STARTUP: lognotedone’

Tracking TODO state changes:

Since it is normally too much to record a note for every state, Org mode expects configuration on a per-keyword basis for this. This is achieved by adding special markers ‘!’ (for a timestamp) or ‘@’ (for a note with timestamp) in parentheses after each keyword. For example, with the setting:

(setq org-todo-keywords
      '((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)")))

You can use the exact same syntax for setting logging preferences local to a buffer:

#+TODO: TODO(t) WAIT(w@/!) | DONE(d!) CANCELED(c@)

In order to define logging settings that are local to a subtree or a single item, define a ‘LOGGING’ property in this entry:

* TODO Only log when switching to WAIT, and when repeating
:PROPERTIES:
:LOGGING: WAIT(@) logrepeat
:END:

Tracking your habits

Checkboxes (todo list)

Checklists [0/4] [0%]:

  • [ ] M-S-RET new checkbox item
  • [ ] RET - dwim command - do what i mean, which in this case toggles state of a TODO entry
  • [ ] while C-c C-c / spc m x will just check/uncheck it
    • [ ] sub item
  • [ ] track the number of items by adding [/] or [0%] to the end of a line above a checklist (and then press C-c C-c) - this updates when you check items off.

C-c C-* - Turn the whole plain list into a subtree of the current heading. Checkboxes (see Checkboxes) become ‘TODO’, respectively ‘DONE’, keywords when unchecked, respectively checked.

Tags #docs

Every headline can contain a list of tags; they occur at the end of the headline. Tags are normal words containing letters, numbers, ‘_’, and ‘@’.

Important note: u cannot search tags in project, those r per-file

Tags can be attached to any headline. Each headline can have multiple tags. Tags r inheritant (all nested headings also have their parents’ tag, but it doesn’t show)

  • SPC m q (org-set-tags-command) - Set the tags for the current visible entry.
  • SPC n m / SPC o a m (org-tags-view) - Show all headlines for all ‘org-agenda-files’ matching tag
  • SPC m s a (org-toggle-archive-tag) - Toggle the archive tag for the current headline.

SPC m s s -> m - use sparse tree to show only those headings matching given tag.

You can also set tags that all entries in a file should inherit just as if these tags were defined in a hypothetical level zero that surrounds the entire file:

#+FILETAGS: :Peter:Boss:Secret:

C-c C-x q - org-toggle-tags-groups (dunno what exactly it does tho 🤔)

Also check fast tag selection

Properties .. #docs

  • SPC m o - org-set-property
  • C-c C-c (org-property-action) - With point in a property drawer, this executes property commands.
    • c (org-compute-property-at-point) Compute the property at point, using the operator and scope from the nearest column format definition.

You may define the allowed values for a particular property ‘Xyz’ by setting a property ‘Xyz_ALL’. This special property is inherited, so if you set it in a level 1 entry, it applies to the entire tree:

:PROPERTIES:
:NDisks_ALL:  1 2 3 4
:Publisher_ALL: "Deutsche Grammophon" Philips EMI
:END:

Properties can be inserted on buffer level. That means they apply before the first headline and can be inherited by all entries in a file. Property blocks defined before first headline needs to be located at the top of the buffer, allowing only comments above.

Properties can also be defined using lines like:

#+PROPERTY: NDisks_ALL 1 2 3 4

Special Properties - provide an alternative access method to Org mode features, like the TODO state or the priority of an entry, discussed in the previous chapters. This interface exists so that you can include these states in a column view (see Column View), or to use them in queries.

C-c / p - Create a sparse tree based on the value of a property. If you enclose the value in curly braces, it is interpreted as a regular expression and matched against the property values.

Property Inheritance:

Org mode has a few properties for which inheritance is hard-coded:

  • COLUMNS
  • CATEGORY
  • ARCHIVE
  • LOGGING

.. and Columns #docs

Properties can be conveniently edited and viewed in column view.

Setting up a column view first requires defining the columns. This is done by defining a column format line.

To specify a format that only applies to a specific tree, add a ‘COLUMNS’ property to the top node of that tree.

A ‘COLUMNS’ property within a property drawer before first headline will apply to the entire file. As an addition to property drawers, keywords can also be defined for an entire file using a line like:

#+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO

Column attributes

Using column view:

  • C-c C-x C-c (org-columns) - Turn on column view.
  • r / g on a columns view line (org-columns-redo) - Recreate the column view, to include recent changes made in the buffer.
  • C-c C-c or q on a columns view line (org-columns-quit) - Exit column view.

Editing values:

Use evil keys to move through the column view from field to field.

  • 1..9,0 - Directly select the Nth allowed value, 0 selects the 10th value.
  • n/p - Switch to the next/previous allowed value of the field.
  • e - Edit the property at point.
  • v - View the full value of this property.
  • a (org-columns-edit-allowed) - Edit the list of allowed values for this

property.

Modifying column view on-the-fly:

  • </> (org-columns-narrow/widen) Make the column narrower/wider by one character.
  • S-M-RIGHT/LEFT (org-columns-new/delete) - Insert a new column, to the left of the current column / Delete the current column.

Dates and Times

Creating Timestamps

[2021-11-09 Вт] - Inactive timestamp. Just like a plain timestamp, but with square brackets instead of angular ones. These timestamps are inactive in the sense that they do not trigger an entry to show up in the agenda.

  • SPC m d t / C-c . (org-time-stamp) - Prompt for a date/time and insert a ti…
  • SPC m d T (org-time-stamp-inactive) - Insert an inactive time stamp.
  • SPC m c -/= (org-clock-timestamps-down/up) - In[de]crease CLOCK timestamps at cursor. On the beginning or enclosing bracket of a timestamp, change its type. Within a timestamp, change the item under point.
  • C-c C-c - Normalize timestamp, insert or fix day name if missing or wrong.
  • C-c < (org-date-from-calendar) - Insert a timestamp corresponding to point date in the calendar.
  • C-c > (org-goto-calendar) Access the Emacs calendar for the current date. If there is a timestamp in the current line, go to the corresponding date instead.

C-c C-x C-t (org-toggle-time-stamp-overlays) - Toggle the use of custom time stamp formats.

To set up custom time format look up format-time-string function doc in emacs, all time-format abbreviations r described there.

Deadline and Scheduling

Warning period of 5 days example: ‘DEADLINE: <2004-02-29 Sun -5d>’

SCHEDULED - Meaning: you are planning to start working on that task on the given date.

Clocking commands

SPC m c prefix:

  • i (org-clock-in) - start the clock onthe current item
  • o (org-clock-out) - stop the currently running clock.
  • I (org-clock-in-last) - re-clock in the last closed clocked item.
  • c / spc n C (org-clock-cancel) - cancel the running clock.
  • g / SPC n o (org-clock-goto) - go to the current clock, or to the most recent.
  • l / SPC n c (+org/toggle-last-clock) - toggle last clocked item.
  • r (org-resolve-clocks) - resolve all currently open Org clocks.

Don’t see much usage:

  • d - org-clock-mark-default-task
  • =/- - Increase / decrease CLOCK timestamps at cursor.

C-c C-x C-d (org-clock-display) - Display time summaries for each subtree in the current buffer. This puts overlays at the end of each headline, showing the total time recorded under that heading, including the time of any subheadings.

The clock table: SPC m c R (org-clock-report) - insert / update clock table.

Effort Estimates:

  • SPC m c e - update effort estimate for cur. clock
  • SPC m c E - org-set-effort
  • C-c C-x E - org-inc-effort

Relative / Countdown Timer

Once started, relative and countdown timers are controlled with the same commands.

C-c C-x prefix ↓

  • 0 - org-timer-start - Start or reset the relative timer
  • ; - org-timer-set-timer - Start a countdown timer
  • . - org-timer - Insert a relative time into the buffer. The first time you use this, the timer starts. Using a prefix argument restarts it.
  • , - org-timer-pause-or-continue
  • - org-timer-item - Insert a description list item with the current relative time. With a prefix argument, first reset the timer to 0.
  • _ - org-timer-stop

M-RET (org-insert-heading) - Once the timer list is started, this command will insert new timer items.

Refile and copy #docs

When reviewing the captured data, you may want to refile or to copy some of the entries into a different list, for example into a project. Cutting, finding the right location, and then pasting the note is cumbersome. To simplify this process, you can use refile.

SPC m r/s r (org-refile) - Move the entry or entries at point to another hea…

Refile current heading (SPC m r prefix) .. :

  • v (+org/refile-to-visible) - .. as first child of visible heading
  • O (+org/refile-to-other-buffer)
  • o (+org/refile-to-other-window)
  • f (+org/refile-to-file) - .. to a particular org file.
  • l (+org/refile-to-last-location) - .. to the last node you refiled
  • c (+org/refile-to-running-clock)
  • . (+org/refile-to-current-file)

SPC m g r (org-refile-goto-last-stored) - Jump to the location where org-refile last moved a tree to.

C-c M-w (org-refile-copy) Copying works like refiling, except that the original note is not deleted.

Archiving #docs

When a project represented by a (sub)tree is finished, you may want to move the tree out of the way and to stop it from contributing to the agenda. Archiving is important to keep your working files compact and global searches like the construction of agenda views fast.

SPC m A (org-archive-subtree) - Move the current subtree to the archive. The archive can be a certain top-level heading in the current file, or in a different file. The tree will be moved to that location, the subtree heading be marked DONE, and the current time will be added.

Internal archiving:

SPC m s a (org-toggle-archive-tag) - Toggle the archive tag for the current headline.

Capture and Attachments

Capture #docs

SPC X / SPC n n (org-capture) - Display the capture templates menu.

SPC n N (org-capture-goto-target) - Go to the target location of a capture template. If TEMPLATE-KEY param is nil, the user is queried for the template.

SPC m g x (org-capture-goto-last-stored)

Capture templates - what i’ve done in my config.el file.

Attachments #docs

org-attach-directory - Customize where attachments will be downloaded. You can set this value per-file with # -*- org-attach-directory: "~/some/path/"; -*-

Prefix SPC m a

  • a - org-attach - select a file and move it into the task’s attachment dir.
  • n - org-attach-new - new attachment as an Emacs buffer
  • S - org-attach-sync - Synchronize the current task with its attachment directory, in case you added attachments yourself.
  • o - org-attach-open - Open current task’s attachment
  • O - org-attach-open-in-emacs - same as above, but force opening in Emacs.
  • r - org-attach-reveal - Open the current task’s attachment directory.
  • R - org-attach-reveal-in-emacs - same, but force using Dired in Emacs.
  • d - org-attach-delete-one
  • D - org-attach-delete-all
  • s - org-attach-set-directory - Set a specific directory as the entry’s attachment directory
  • l - +org/attach-file-and-insert-link
  • u - org-attach-url
  • f - +org/find-file-in-attachments

Not bound to <leader> system (C-c C-a prefix):

  • b (org-attach-buffer) - select a buffer and save it as a file in the task’s attachment directory.

Automatic version-control with Git:

If the directory attached to an outline node is a Git repository, Org can be configured to automatically commit changes to that repository when it sees them:

(require 'org-attach-git)

Agenda views #docs

Org can select items based on various criteria and display them in a separate buffer. Six different view types are provided:

  • an agenda that is like a calendar and shows information for specific dates,
  • a TODO list that covers all unfinished action items,
  • a match view, showings headlines based on the tags, properties, and TODO state associated with them,
  • a text search view that shows all entries from multiple files that contain specified keywords,
  • a stuck projects view showing projects that currently do not move along, and
  • custom views that are special searches and combinations of different views.

Two variables control how the agenda buffer is displayed and whether the window configuration is restored when the agenda exits: org-agenda-window-setup and org-agenda-restore-windows-after-quit.

org-agenda-files - stores all your agenda files. They add up automatically when there is a new entry in any file.

Main org-agenda prefix - SPC o a

  • a - org-agenda (also SPC o A / SPC n a)
  • t - org-todo-list
  • m - org-tags-view
  • v - org-search-view

Date/deadline prefix SPC m d

  • t - org-time-stamp
  • T - org-time-stamp-inactive
  • s - org-schedule
  • d - org-deadline

Notes prefix SPC n:

  • F - +default/browse-notes – see all files with your notes including agendas and todos
  • S - +default/org-notes-headlines – Jump to an Org headline in org-agenda-files.
  • s - +default/org-notes-search – Perform a text search on org-directory.
  • t - org-todo-list
  • v - org-search-view - Show all entries that contain a phrase or words or regular expressions.

Other kbds:

  • C-# org-table-rotate-recalc-marks
  • C-’ org-cycle-agenda-files
  • C-c C-x < / > org-agenda-set(remove)-restriction-lock

Markup for Rich Contents #docs

Paragraphs

Paragraphs are separated by at least one empty line. If you need to enforce a line break within a paragraph, use ‘\’ at the end of a line.

When quoting a passage from another document, it is customary to format this as a paragraph that is indented on both the left and the right margin — docs

<c - centred text (only after it is exported tho 🙁):

Everything should be made as simple as possible,
but not any simpler

Emphasis and Monospace

*bold*
/italic/
_underlined_
=verbatim= (literal text)
~code~
+strikethrough+ (if you must ..)

Text in the code and verbatim string is not processed for Org specific syntax; it is exported verbatim.

Subscripts and Superscripts

‘^’ and ‘_’ are used to indicate super- and subscripts. To increase the readability of ASCII text, it is not necessary, but OK, to surround multi-character sub- and superscripts with curly braces. For example:

The radius of the sun is R_sun = 6.96 x 108 m. On the other hand, the radius of Alpha Centauri is RAlpha Centauri = 1.28 x Rsun.

You can also toggle the visual display of super- and subscripts:

C-c C-x \ (org-toggle-pretty-entities) - format sub- and superscripts in a WYSIWYM way.

Special Symbols

You can use LaTeX-like syntax to insert special symbols—named entities—like ‘α’ to indicate the Greek letter, or ‘→’ to indicate an arrow. Completion for these symbols is available, just type ‘\’ and your completion keystroke.

A large number of entities is provided, with names taken from both HTML and LaTeX; you can comfortably browse the complete list from a dedicated buffer using the command org-entities-help. It is also possible to provide your own special symbols in the variable org-entities-user.

During export, these symbols are transformed into the native format of the exporter back-end. Strings like ‘α’ are exported as ‘&alpha;’ in the HTML output, and as ‘\(α\)’ in the LaTeX output. Similarly, ‘ ’ becomes ‘&nbsp;’ in HTML and ‘~’ in LaTeX.

In addition to regular entities defined above, Org exports in a special way109 the following commonly used character combinations: ‘-’ is treated as a shy hyphen, ‘–’ and ‘—’ are converted into dashes, and ‘…’ becomes a compact set of dots.

Literal Exmaples

You can include literal examples that should not be subjected to markup.
Such examples are typeset in monospace, so this is well suited for source
code and similar examples.

* I am no real headline

However, you must insert a comma right before lines starting with either ‘*’, ‘,*’, ‘#+’ or ‘,#+’, as those may be interpreted as outlines nodes or some other special syntax. Org transparently strips these additional commas whenever it accesses the contents of the block ↑

For simplicity when using small examples, you can also start the example lines with a colon followed by a space.

There may also be additional whitespace before the colon

Both in ‘example’ and in ‘src’ snippets, you can add a ‘-n’ switch to the end of the ‘#+BEGIN’ line, to get the lines of the example numbered. The ‘-n’ takes an optional numeric argument specifying the starting line number of the block. If you use a ‘+n’ switch, the numbering from the previous numbered snippet is continued in the current one. The ‘+n’ switch can also take a numeric argument. This adds the value of the argument to the last line of the previous block to determine the starting line number.

;; This exports with line number 20.
(message "This is line 21")
;; This is listed as line 31.
(message "This is line 32")

In literal examples, Org interprets strings like ‘(ref:name)’ as labels, and use them as targets for special hyperlinks like ‘(name)’—i.e., the reference name enclosed in single parenthesis. In HTML, hovering the mouse over such a link remote-highlights the corresponding code line, which is kind of cool.

You can also add a ‘-r’ switch which removes the labels from the source code. With the ‘-n’ switch, links to these references are labeled by the line numbers from the code listing. Otherwise links use the labels with no parentheses. Here is an example:

(save-excursion                 (ref:sc)
   (goto-char (point-min))      (ref:jump)

In line (sc) we remember the current position. Line (jump) jumps to point-min.

Formatted blocks of text (expand with tab and edit with SPC m ' / C-c '):

Images

how to paste local img/gifs into document

An image is a link to an image file118 that does not have a description part. If you wish to define a caption for the image (see Captions) and maybe a label for internal cross references (see Internal Links), make sure that the link is on a line by itself and precede it with ‘CAPTION’ and ‘NAME’ keywords as follows:

~/Pictures/xXfymMYfBFM.jpg

z i - org-toggle-inline-images

org-yt - youtube links (with imgs) in org mode:

lo-fi beats

Captions

You can assign a caption to a specific part of a document by inserting a ‘CAPTION’ keyword immediately before it:

Optionally, the caption can take the form:

#+CAPTION[Short caption]: Longer caption.

Even though images and tables are prominent examples of captioned structures, the same caption mechanism can apply to many others—e.g., LaTeX equations, source code blocks. Depending on the export back-end, those may or may not be handled.

Horizonatal Rules

A line consisting of only dashes, and at least 5 of them, is exported as a horizontal line:


Footnotes #docs

SPC m f (org-footnote-new) - insert a footnote in current document (call with universal to get ‘action’ propmt)

C-c C-x f (org-footnote-action)

Working with Souce Code #docs

Source code blocks

A source code block conforms to this structure:

#+NAME: <name>
#+BEGIN_SRC <language> <switches> <header arguments>
<body>
#+END_SRC

Org mode offers a command for wrapping existing text in a block (see Structure Templates).

Regular use of templates reduces errors, increases accuracy, and maintains consistency.

An inline code block conforms to this structure:

src_<language>{<body>} or src_<language>[<header arguments>]{<body>}
‘#+NAME: <name>’
Optional. Names the source block so it can be called, like a function, from other source blocks or inline code to evaluate or to capture the results. Code from other blocks, other files, and from table formulas (see The Spreadsheet) can use the name to reference a source block. This naming serves the same purpose as naming Org tables. Org mode requires unique names. For duplicate names, Org mode’s behavior is undefined.
‘<switches>’
Optional. Switches provide finer control of the code execution, export, and format (see the discussion of switches in Literal Examples).
‘<header arguments>’
Optional. Heading arguments control many aspects of evaluation, export and tangling of code blocks (see Using Header Arguments). Using Org’s properties feature, header arguments can be selectively applied to the entire buffer or specific sub-trees of the Org document.

Unuseful for me at the moment [2021-11-12 Пт]

Using Header Arguments

All of the following is in docs:

  • System-wide header args list and their defaults
  • Apply header arguments buffer-/header-wide
  • Multi-line header arguments per block
  • Highest-priority header arguments in func calls (#+CALL:)

Environment of a Code Block

:var NAME=ASSIGN

Also in docs:

  • passing name by reference (even from another file)
  • passing values when calling source code blocks
  • working with tables
  • using sessions, working directories
  • inserting headers and footers

… and pretty much everything else u can find in main tree docs..

Unsorted

]/[ c - next / prev src block

After ‘python’ keyword on line below you can write the output of the code to a var and use it in next code-block

import random
return [random.randrange(1, 20)
        for i in range( random.randrange(1, 20))]

after u execute this (C-c C-c) the output will appear below and ‘pythonic-numbers’ will contain value

(length numbers)

Completion #start-of-misc-section

Complete word at point (with C-SPC in case of doom):

  • At the beginning of an empty headline, complete TODO keywords.
  • After ‘\’, complete TeX symbols supported by the exporter.
  • After ‘:’ in a headline, complete tags. Org deduces the list of tags from the ‘TAGS’ in-buffer option (see Setting Tags), the variable org-tag-alist, or from all tags used in the current buffer.
  • After ‘:’ and not in a headline, complete property keys. The list of keys is constructed dynamically from all keys used in the current buffer.
  • After ‘#+’, complete the special keywords like ‘TYP_TODO’ or file-specific ‘OPTIONS’. After option keyword is complete, pressing M-TAB again inserts example settings for this keyword.
  • After ‘STARTUP’ keyword, complete startup items.

Structure Templates

View var org-structure-template-alist

C-c C-, (org-insert-structure-template) - Prompt for a type of block structure, and insert the block at point.

.. or just <{pref.key} TAB

The Very Busy C-c C-c Key

  • If column view (see Column View) is on, exit column view.
  • If any highlights shown in the buffer from the creation of a sparse tree, or from clock display, remove such highlights.
  • If point is in one of the special ‘KEYWORD’ lines, scan the buffer for these lines and update the information. Also reset the Org file cache used to temporary store the contents of URLs used as values for keywords like ‘SETUPFILE’.
  • If point is inside a table, realign the table.
  • If point is on a ‘<<<target>>>’, update radio targets and corresponding links in this buffer.
  • If point is on a property line or at the start or end of a property drawer, offer property commands.
  • If point is at a footnote reference, go to the corresponding definition, and vice versa.
  • If point is on a statistics cookie, update it. ([/] and [%] in todo lists)
  • If point is on a numbered item in a plain list, renumber the ordered list.
  • If point is on the ‘#+BEGIN’ line of a dynamic block, the block is updated.
  • If point is at a timestamp, fix the day name in the timestamp.

In-Buffer Settings #docs

In-buffer settings start with ‘#+’, followed by a keyword, a colon, and then a word for each setting. Org accepts multiple settings on the same line.

C-c C-c activates any changes to the in-buffer settings.

‘#+ARCHIVE: %s_done::’ :: agenda file name
location
‘#+CATEGORY’
category of agenda file
‘#+COLUMNS: %25ITEM …’
default format for columns view. This format applies when columns view is invoked in locations where no ‘COLUMNS’ property applies.
‘#+FILETAGS: :tag1:tag2:tag3:’
Set tags that all nested entries inherit.
‘#+PRIORITIES: highest lowest default’
This line sets the limits and the default for the priorities. All three must be either letters A–Z or numbers 0–9. The highest priority must have a lower ASCII number than the lowest priority.
‘#+PROPERTY: Property_Name Value’
This line sets a default inheritance value for entries in the current buffer, most useful for specifying the allowed values of a property.
‘#+SETUPFILE: file’
The setup file or a URL pointing to such file is for additional in-buffer settings. Org loads this file and parses it for any settings in it only when Org opens the main file. If URL is specified, the contents are downloaded and stored in a temporary file cache. C-c C-c on the settings line parses and loads the file, and also resets the temporary file cache. Org also parses and loads the document during normal exporting process. Org parses the contents of this document as if it was included in the buffer. It can be another Org file. To visit the file—not a URL—use C-c ’ while point is on the line with the file name.
‘#+STARTUP:’
Startup options Org uses when first visiting a file.
initial visibility
Initial visibility
‘(no)inlineimages’
Show/hide inline images.
logging settigns
look up docs page for ‘em
‘customtime’
Turn on custom format overlays over timestamps (variables org-put-time-stamp-overlays and org-time-stamp-overlay-formats).
footnotes settings
Those also look up on docs page.
‘(no)hideblocks’
hide/nohide blocks on startup, use these keywords. The corresponding variable is org-hide-block-startup.
‘entitiespretty(plain)’
display of entities as UTF-8/plain characters is governed by the variable org-pretty-entities and the keywords
‘#+TAGS: TAG1(c1) TAG2(c2)’
These lines (several such lines are allowed) specify the valid tags in this file, and (potentially) the corresponding fast tag selection keys. The corresponding variable is org-tag-alist.
‘#+TODO:’, ‘#+SEQ_TODO:’, ‘#+TYP_TODO:’
set the TODO keywords and their interpretation in the current file. The corresponding variable is org-todo-keywords.

Org Syntax #docs

Probe the syntax of your org doc with command org-lint. From here C-j / TAB to display the offending line.

From draft on Worg:

Affiliated Keywords

With the exception of comment, clocks, headlines, inlinetasks, items, node properties, planning, property drawers, sections, and table rows, every other element type can be assigned attributes.

This is done by adding specific keywords, named “affiliated keywords”, just above the element considered, no blank line allowed.

Affiliated keywords are built upon one of the following patterns:

#+KEY: VALUE
#+KEY[OPTIONAL]: VALUE
#+ATTR_BACKEND: VALUE

KEY is either “CAPTION”, “HEADER”, “NAME”, “PLOT” or “RESULTS” string.

BACKEND is a string constituted of alpha-numeric characters, hyphens or underscores.

OPTIONAL and VALUE can contain any character but a new line. Only “CAPTION” and “RESULTS” keywords can have an optional value.

An affiliated keyword can appear more than once if KEY is either “CAPTION” or “HEADER” or if its pattern is “#+ATTRBACKEND: VALUE”.

“CAPTION”, “AUTHOR”, “DATE” and “TITLE” keywords can contain objects in their value and their optional value, if applicable.

Context Dependent Documentation

C-c C-x I - tries to open a suitable section of the Org manual depending on the syntax at point. For example, using it on a headline displays “Document Structure” section.

Tables #docs

C-c C-c / RET / TAB - re-align table automatically

NamePhoneAge
Peter123417

To create the above table, you would only type ‘|Name|Phone|Age’ followed by ‘C-c <RET>’.

SPC m b prefix ↓

h
field-*info*
c
create-or-convert-from-region. Create an empty table / convert selected text to a table
a
align
- / i h(H)
insert-*hline* (H for hline-and-move)
i/d c/r
insert / delete column / row
b
blank-field
s
sort-lines
e
edit-field
t o
toggle-coordinate-overlays
f
edit-formulas
t f
toggle-formula-debugger
R
recalculate-buffer-tables
r
recalculate

Creation and conversion

‘C-c |’ (‘org-table-create-or-convert-from-region’) - Convert the active region to table. If every line contains at least one ‘<TAB>’ character, the function assumes that the material is tab separated. If every line contains a comma, comma-separated values (CSV) are assumed. If not, lines are split at whitespace into fields. You can use a prefix argument to force a specific separator: ‘C-u’ forces CSV, ‘C-u C-u’ forces ‘<TAB>’, ‘C-u C-u C-u’ prompts for a regular expression to match the separator, and a numeric argument N indicates that at least N consecutive spaces, or alternatively a ‘<TAB>’ will be the separator.

If there is no active region, this command creates an empty Org table. But it is easier just to start typing, like ‘| Name | Phone | Age <RET> |- <TAB>’.

Re-aligning and field motion

‘C-c C-c’ (align)
Re-align the table without moving point.
<TAB> / S-<TAB>
next-field / previous-field
‘C-c <SPC>’ (blank-field)
Blank the field at point.
‘<RET>’ (next-row)
Creates a new row if necessary. At the beginning or end of a line, ‘<RET>’ still inserts a new line, so it can be used to split a table.
M-a/e (beginning/end-of-field)
Move to beginning/end of the current table field, or on to the previous/next field.

Column and row editing

M-h/j/k/l
move row / column
M-S-h/j/k/l
kill cur. row (k) / insert row above cur. row (j) / kill cur. col (h) / insert new col at point (l)
S-h/j/k/l
move cells around
C-c - (insert-hline)
Insert a horizontal line below current row. With a prefix argument, the line is created above the current line.
C-c <RET> (hline-and-move)
Insert a horizontal line below current row, and move point into the row below that line.
C-c ^ (sort-lines)
Sort the table lines in the [region]. The position of point indicates the column to be used for sorting, and the range of lines is the range between the nearest horizontal separator lines, or the entire table. When called with a prefix argument, alphabetic sorting is case-sensitive.

If SORTING-TYPE is specified when this function is called from a Lisp program, no prompting will take place. SORTING-TYPE must be a character, any of (?a ?A ?n ?N ?t ?T ?f ?F) where the capital letters indicate that sorting should be done in reverse order.

If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies a function to be called to extract the key. It must return a value that is compatible with COMPARE-FUNC, the function used to compare entries.

A non-nil value for INTERACTIVE? is used to signal that this function is being called interactively.

Regions (copy / cut / paste / split)

C-c C-x M-w (copy-region)
Copy a rectangular region from a table to a special clipboard. If there is no active region, copy just the current field. The process ignores horizontal separator lines.
C-c C-x C-w (cut-region)
Cut a rectangular region from a table to a special clipboard, and blank all fields in the rectangle.
C-c C-x C-y (paste-rectangle)
Paste a rectangular region into a table. The upper left corner ends up in the current field. All involved fields are overwritten. The process ignores horizontal separator lines.
M-<RET> (wrap-region)
Split the current field at point position and move the rest to the line below. If there is an active region, and both point and mark are in the same column, the text in the column is wrapped to minimum width for the given number of lines. A numeric prefix argument may be used to change the number of desired lines. If there is no region, but you specify a prefix argument, the current field is made blank, and the content is appended to the field above.

Calculations (sum / copy down)

C-c + (sum)
Sum the numbers in the current column, or in the rectangle defined by the active region. The result is shown in the echo area and can be inserted with ‘C-y’.
S-<RET> (copy-down)
When current field is empty, copy from first non-empty field above. When not empty, copy current field down to next row and move point along with it. Depending on the variable ‘org-table-copy-increment’, integer and time stamp field values, and fields prefixed or suffixed with a whole number, can be incremented during copy. Also, a ‘0’ prefix argument temporarily disables the increment.

Miscellaneous (edit / import / export / transpose / hline-mode)

C-c ` (edit-field)
Edit the current field in a separate window. This is useful for fields that are not fully visible (see *note Column Width and Alignment::). When called with a ‘C-u’ prefix, just make the full field visible, so that it can be edited in place. When called with two ‘C-u’ prefixes, make the editor window follow point through the table and always show the current field. The follow mode exits automatically when point leaves the table, or when you repeat this command with ‘C-u C-u C-c `’.
C-c ? (field-info)
Show info about the current field, and highlight any reference at point.
‘M-x org-table-import’
Import a file as a table. The table should be TAB or whitespace separated. This command works by inserting the file into the buffer and then converting the region to a table. Any prefix argument is passed on to the converter, which uses it to determine the separator.
‘M-x org-table-export’
Export the table, by default as a TAB-separated file. (spc h f this func for further info)
‘M-x org-table-header-line-mode’
Turn on the display of the first data row of the table at point in the window header line when this first row is not visible anymore in the buffer. You can activate this minor mode by default by setting the option ‘org-table-header-line-p’ to ‘t’.
‘M-x org-table-transpose-table-at-point’
Transpose the table at point and eliminate hlines.

Column Width and Alignment

Setting the option ‘org-startup-align-all-tables’ re-aligns all tables in a file upon visiting it. You can also set this option on a per-file basis with:

Maybe you want to hide away several columns or display them with a fixed width.

To set the width of a column, one field anywhere in the column may contain just the string ‘<N>’ where N specifies the width as a number of characters. You control displayed width of columns with the following tools:

C-c <TAB> (toggle-column-width)
Shrink or expand current column.
If a width cookie specifies a width W for the column, shrinking it displays the first W visible characters only. Otherwise, the column is shrunk to a single character.
C-u C-c <TAB> (shrink)
Shrink all columns with a column width. Expand the others.
C-u C-u C-c <TAB> (expand)
Expand all columns. Alternatively, ‘C-h .’ (‘display-local-help’) reveals them, too.

Setting the option ‘org-startup-shrink-all-tables’ shrinks all columns containing a width cookie in a file the moment it is visited. You can also set this option on a per-file basis with:

To get more on alignment of number-rich columns go to ‘Info’ section called after cur. org header.

Column Groups | Orgtbl Minor Mode

–> Info ^^

For the format, type orgtbl-to and press TAB to see the available options (e.g. orgtbl-to-csv will convert to csv in the output file)

Use formulae to do arithmetic on tables, and use them like a spreadsheet.

Narrowing C-x n ..

spc m s n (org-narrow-to-subtree) - narrow buffer to current subtree (N to widen)

Org-narrow prefix C-x n ↓ b - org-narrow-to-block s - org-narrow-to-subtree e - org-narrow-to-element

Journal

SPC n j prefix ↓

  • j - new journal entry
  • J - new scheduled entry
  • s - search forever. Search for a string within all entries.

While in a journal file - spc n j j again to make another entry right away.

Additional: usage with calendar

Other rarely used stuff

Babel

Org-babel prefix - C-c C-v ↓ a - sha1-hash b - execute-buffer c - check-src-block d - demarcate-block e - execute-maybe f - tangle-file g - goto-named-src-block h - describe-bindings i - lob-ingest j - insert-header-arg k - remove-result-one-or-many l - load-in-session n - next-src-block o - open-src-block-result p - previous-src-block r - goto-named-result s - execute-subtree t - tangle u - goto-src-block-head v - expand-src-block x - do-key-sequence-in-edit-buffer z - switch-to-session-with-code I - view-src-block-info TAB - view-src-block-info C-a - sha1-hash

Exporting .org file #docs

org-clipboard - exports buffer / selected text to clipboard, spc n y/Y (look up the commands to see docs)

SPC m e (org-export-dispatch) - export file, then choose needed options

Examples:

  • h o - export to HTML and open it
  • l o - export to latex and compile it to produce a pdf and open it

Also check how to tweak the look of exported file here

Org publishing #docs

Org includes a publishing management system that allows you to configure automatic HTML conversion of projects composed of interlinked Org files. You can also configure Org to automatically upload your exported HTML pages and related attachments, such as images and source code files, to a web server.

SPC m P - prefix

Unsorted for now

g Q - org-fill-paragraph

z n - org-tree-to-indirect-buffer

Motions in <operator-state> (i prefix for inner; a for an):

  • E - element
  • e - object
  • R - subtree
  • r - greater-element

Executing source code blocks

Org-mode can execute your source code blocks and add the output to your file. This part of org-mode is called babel

echo "Hello $USER! Today is `date`"
exit

> text below is executed via C-c C-c, while cursor on block above