Consultancy - Research Lab - Incubator

based in beautiful Zürich, Switzerland

- 240 words - 2 min read

Update: This is a re-post of an older blog post of mine. Originally it was posted on my personal blog. I'm deprecating my personal blog in favor of this 200OK blog.

You can use templates for different types of capture items, and for different target locations.

The following code sets up three capture templates – for todos, media urls and code snippets (lines 4-7).

%? sets the exit point for the template, %^g prompts for a tag, %^{language} prompts for the language of the snippet and the remainder is boilerplate to create an org-mode entry (*) and an org-mode snippet (#+BEGIN_SRC\n\n#+END_SRC).

(setq org-capture-templates
       '(("t" "Todo" entry (file+headline (concat org-directory "") "Tasks")
          "* TODO %?\n  %U\n  %i\n  %a")
        ("s" "Code Snippet" entry
         (file (concat org-directory ""))
         ;; Prompt for tag and language
         "* %?\t%^g\n#+BEGIN_SRC %^{language}\n\n#+END_SRC")
         ("m" "Media" entry
          (file+datetree (concat org-directory ""))
          "* %?\nURL: \nEntered on %U\n")))