Org Mode Easy templates of your own
First of all,Take a look at some of the pre-defined easy templates of org-mode press here .
So , how would u execute this?
Type '<' followed by the template selector and press
When you press
<s TAB , you will see:
Create your own template
After the basic concept of easy template blocks in org mode, let's take a look at how we can write our own template that can be used whenever and wherever you want in the org file.
Open up your .emacs or .emacs.d/init.el ( emacs config file ) file and write some emacs lisp.
(add-to-list 'org-structure-template-alist '("S" "#+begin_src ?\n echo hello world \n#+end_src"))
Too confusing? let me explain.. org-structure-template-alist contains all the easy templates and we are just adding ours to that list. The letter S is the template selector, and the next block is the contents we want to keep into our template. In above example #+beginsrc is the opening of the source block. ? after that prompts the user which programming language you want to use and \n stands for two next lines. echo hello world is the bash code i kept inside the block and of course #+endsrc is for telling org mode that the source block ends here.
Don't forget to evaluate that lisp code. To do that press
Now, in any org mode file press <S TAB then it will be executed.
Here is an example:
(add-to-list 'org-structure-template-alist '("C" "#+begin_html \n <div class=\"code-block\"> \n #+end_html \n #+begin_src ?\n\n #+end_src \n #+begin_html \n </div> \n #+end_html" ))