org-mode: capture templates - How to use them?
org-capture
lets you save (quickly!) links (in a broad sense) to you work for later reference. For example, say that you work on some TeX
file, and you realize that you miss a section. Instead of cutting your workflow, you simply hit M-x org-capture
and save a quick note (with a link to the place in the TeX
file) in your Get Things Done org
-file.
In order to use this feature, you have to define certain files where you want to save those quick notes. For example, for me, the most important file is gtd.org
where I accomulate all the todo's. In turn, it is useful to add this file to the agenda list (M-x org-agenda-file-to-front
) so you can access easily todo lists.
The templates I use are defined as follows:
(setq org-capture-templates
(quote (("t" "todo" entry (file (concat org-directory "/gtd.org"))
"* TODO %?\n%U\n%a\n" :clock-in t :clock-resume t)
("n" "note" entry (file (concat org-directory "/gtd.org"))
"* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
("j" "Journal" entry (file+datetree (concat org-directory "/diary.org"))
"* %?\n%U\n" :clock-in t :clock-resume t)
)))
And I mainly use the t
for the todos. In practice, I binded (or maybe it is the default) org-capture
to C-c c
and then C-c c t
opens a buffer where I can edit the todo item. Once I'm done C-c C-c
saves the note in the predefined place, and I'm thrown automatically back to the buffer and point in the buffer where I was.
As always: for example C-c
means that you have to hit the CONTROC-c
combination and similarly M-x
means that you have to hit META-x
(META
is normally ALT
).
Related videos on Youtube
Dox
Updated on September 18, 2022Comments
-
Dox over 1 year
I've started using
emacs
'sorg-mode
often, and finally I get to configureorg-capture
.However, I've found in most places that one can configure different templates by adding the following lines to the
.emacs
file:(setq org-capture-templates '(("t" "Todo" entry (file+headline "~/Documents/Orgfiles/gtd.org" "Tasks") "* TODO %?\n %i\n %a") ("j" "Journal" entry (file+datetree "~/Documents/Orgfiles/journal.org") "* %?\nEntered on %U\n %i\n %a")))
Question
- What is the purpose of using these templates?
- Could you (please) illustrate their uses with some examples?
-
lawlist over 10 yearsThese are used to save time for certain types of entries that are repetitive. I have templates for tasks (things to do), and for events (appointments, holidays, birthdays, etc.). Whatever information that is most commonly inserted is stored in the template. You can even include a specific date, such as today for the deadline.
-
Anupam over 6 yearsI just ran into a problem with a setup similar to this one, i.e. instead of an ordinary string for the file name I constructed one. That stopped working after a recent update and I had to modify it,
(concat org-directory "/gtd.org")
had to be changed to(lambda () (concat org-directory "/gtd.org"))
.