2

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

  #+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.

4
  • @echristopherson please don't down vote people for posting duplicates. Not even if they're dupes from the same site (in that case just flag/close) and most certainly not if they're dupes on other sites. Instead take one of the other answers, adapt as necessary and post it here (giving the source, obviously). See here and here.
    – terdon
    Oct 3, 2013 at 1:40
  • Sorry about that. I tried to take back my vote but it's been too long. Oct 3, 2013 at 13:26
  • @echristopherson no worries, try again, you should be able to retract now that the post has been edited. You may as well make an answer out of the linked ones and get some rep :).
    – terdon
    Oct 4, 2013 at 17:41

1 Answer 1

1

This is possible using so-called Easy Templates. See the org-mode manual for the default list.

If you add the following to your .emacs file, you will be able to insert a comment by simply typing <c followed by the TAB key for a comment or <e[TAB] for an example, etc.:

(setq org-structure-template-alist
  '(("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")
    ("e" "#+begin_comment\n?\n#+end_comment"))

Note that this will overwrite the default Easy Templates. To add your Easy Template to the default list without overwriting the whole list (although the default <e for the default example environment will be overwritten) add this to your .emacs:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .