Inline code in org-mode

blueFast picture blueFast · Apr 24, 2013 · Viewed 25.9k times · Source

Markdown allows for embedded code. How can this be done in org-mode?

I know about source-code blocks:

#+begin_example
blah-blah
#+end_example

But what I want is something like this (obviously, with the right syntax, which I do not know):

This is `embeded code`.

Can this be done in org-mode? Not possible to find that in the documentation ...

Answer

Tom Regner picture Tom Regner · Apr 24, 2013

While monospaced is good enough for most cases, inline code blocks have the form src_LANG[headers]{your code}. For example, src_xml[:exports code]{<tag>text</tag>}.

Edit: Code highlighting of inline code is certainly possible, albeit with patching org.el itself: The answer given here https://stackoverflow.com/a/20652913/594138 works as advertised, turning

- Inline code src_sh[:exports code]{echo -e "test"}

Into

enter image description here

in html-export. And the winning answer in this post, https://stackoverflow.com/a/28059832/594138, achieves the same without the need to patch org.el, but you will have to adapt it if you don't like the optics during editing.