Files As Org Capture Templates

Josh Rollins has a very nice tip on a feature of Org-mode capture templates that I didn’t know about. It turns out that you can store a capture template in a file. It’s not immediately clear what that means exactly or why you’d want to do it in the first place.

The main use case appears to be a long and complicated template, possibly with formatting. In Rollins’ case, the template is a check list for setting up new computers (Rollins is an IT support technician). When a request is initiated for a new computer, he wants to capture the essential data and add the check list to his project file. I have a similar requirement that I handle by having a yasnippet expand to my desired body but that’s not as seamless as Rollins’ method.

What goes into the file is the string containing the text and substitution escape codes. That makes it easy to have a complicated body of data along with special formatting. In Rollins’ case, he wants the indentation of sublists to be correct, something he couldn’t figure out how to do with the usual method of specifying templates. The file mechanism is invoked by replacing the string containing the text and escape codes with the form

(file "file-containing-template")

where the "file-containing-template" contains the text that would normally be in the text string of the capture template. Take a look at Rollins’ post for more details. If you use the capture facility a lot, this tip will probably be useful to you.

This entry was posted in General and tagged , . Bookmark the permalink.