Search code examples
emacsorg-mode

Emacs org-mode - format source block


Is it possible to get org-mode to use indentation rules of the specified language? For example, if I have the code below, I'd like var x; to indent properly when I hit the tab key (just as it would in javascript mode).

#+BEGIN_SRC javascript
function foo() {
var x;
}
#+END_SRC

I have set (setq org-src-fontify-natively t) which has enabled syntax highlighting, but not code formatting.


Solution

  • Customize the option org-src-tab-acts-natively to t. With this setting tab works as you expect it in the source code block. The additional indentation by two spaces is removed if you tangle the source code block or edit it with C-c '. My org-version is 8.2.5h.