3

I use org-mode to maintain my personal site. Whenever I create a new .org file in my website, I find myself retyping the following

#+TITLE: 
#+OPTIONS: html-postamble:nil whn:nil toc:nil nav:nil
#+HTML_HEAD:
#+HTML_HEAD_EXTRA: 

Is it possible to bind this template to a keystroke?

  • 1
    Are you willing to use Yasnippet? – Dan Aug 3 '17 at 22:07
  • I'm willing to learn anything that works! – Brian Fitzpatrick Aug 3 '17 at 22:30
  • I use autoinsert mode for this purpose. No keystrokes to learn. – Juancho Aug 3 '17 at 23:52
3

You can use the templating system of org-mode. If you insert the following lines at the end of your init.el file:

(add-to-list 'org-structure-template-alist
             '("P" "#+TITLE:\n#+OPTIONS: html-postamble:nil whn:nil toc:nil nav:nil\n#+HTML_HEAD:\n#+HTML_HEAD_EXTRA:\n\n? "))

After you restart emacs or source your init.el file, you only have to type <P at the beginning of your org-mode file, then the <TAB> key and this will automatically integrate the desired code.

See http://orgmode.org/manual/Easy-templates.html for the documentation of the template mechanism.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.