Setting Up Org Mode Source Code Block Snippets In Spacemacs (Emacs)
TODO : Roll this into the other post where you show the actual snippets that you used (assuming you can find it)
ID of the other post is : 2afrtrcdfbfn
Took a bit to figure this one out. The goal it to setup snippets that auto expand into Org mode source code blocks. By default, you can type "SPC m i b s" when you're not in edit mode to generate a generic source code block like this :
#+begin _ example
# _ +begin _ src
# _ +end _ src
#+end _ example
That's a lot of keys and you still have to define the language and any other options. I made the following additions to the [TODO: Code shorthand span ] section at the bottom of my [TODO: Code shorthand span ] config file to make it nicer.
(defun dotspacemacs/user-config ()
(require 'org-tempo)
(add-to-list 'org-structure-template-alist
'("j" . "src js :results output"))
(add-to-list 'org-structure-template-alist
'("p" . "src python :results output"))
)
The [TODO: Code shorthand span ] line turns on some default snippet expansions like [TODO: Code shorthand span ] followed by TAB at the start of a line (in INSERT mode) for the basic begin/end src block.
The [TODO: Code shorthand span ] items let me type [TODO: Code shorthand span ] followed by TAB and [TODO: Code shorthand span ] followed by a TAB to generate :
#+begin _ example
# _ +begin _ src js : results output
# _ +end _ src
#+end _ example
and
#+begin _ example
# _ +begin _ src python : results output
# _ +end _ src
#+end _ example