Search code examples
emacsorg-modekey-bindings

Shortcut for inserting environments in `org-mode`


I'm using org-mode for organizing myself (very useful so far!). However, it is kind of annoying writting

  #+begin_comment
  ...
  #+end_comment

each time I'd like to insert an environment.

Question

Is there a shortcut to insert the #+begin_ and #+end_ for a given environment?

In the same way C-c C-o comment RET would insert

\begin{comment}

\end{comment}

in latex-mode.


Solution

  • Org has a facility called "Easy templates": http://orgmode.org/manual/Easy-Templates.html

    A template for comment is missing but you can add it with:

    (add-to-list 'org-structure-template-alist '("C" "#+begin_comment\n?\n#+end_comment"))
    

    And use it by typing <C followed by TAB.

    Alternatively, you could use yasnippet.