HANDLING External Links
Relevant Section in Org Manual
Note: Org links can be typed up manually. One can emply hippie expand to expand them. The method below allows for automatic copying and pasting in the correct syntax, which also reduces error.
The main commands for handling links
The main commands to create a link in the correct syntax are:
org-store-link
which I bind to (global-set-key (kbd "C-c l") #'org-store-link)
org-insert-link
which is bound by default to C-c C-l
org-store-link
is a context sensitive command
- Run on a file generally it copies the full file path and prompts for a description when inserted
- Run on a Heading it copies the full file path + the heading
- Run on a CUSTOMID it will do the same
- Run on the same
- When you insert a link org will provide you with a menu with copied links + the ability to enter identifiers and their colon (
alt+v
takes one to the menu).
Outside orgmode buffers
One can also use org-store-link
outside an org buffer to create a link:
- Most Emacs mail clients are supported
- Web browsers too: W3M and EWW
- In a Dired buffer it copies the link under the cursor (similar to M-0 w)
- It also can copy links to non-org files, as well as to lines and sections based on the position of the cursor and/or a region.
For example this link takes me to a section in my dot Emacs:
[[file:~/.emacs::whisper][Whisper]]
- One can even create links to Agenda Items in Agenda View
More on inserting links
- The up arrow gives the last created link
- One can navigate link history using up/down arrows or
M-p
andM-n
TAB
shows you a list of links and provides completion support
Invoke C-c C-l Type "file:" Hit RET
alt-v
takes you into the completions buffer- If you invoke the prefix (
C-u
) withC-c C-l
you go straight to insert file link and can insert a relative link - If you invoke
C-u
twice you force an absolute link (give an example)
earth-day.html
file:///home/yal/Files-2024/orgmode-series/earth-day.html - On an existing link invoking
C-c C-l
allows for editing a link
Opening Links with C-c C-o
links
C-c C-o
provides different results based on the context.
Position your cursor on different meta text and see different results!
For example: on tags, time-stamps, URLs- Invoking it on a link with a certain file type will open the file in its default application. To open in Emacs use a
C-u
prefix.
Hot customisations
Use RET
instead of C-c C-o
to open a link (C-c C-o can become tedious)
org-return-follows-link
Jump quickly between links
(with-eval-after-load 'org (define-key org-mode-map (kbd "M-n") #'org-next-link) (define-key org-mode-map (kbd "M-p") #'org-previous-link))