Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs org-mode - format source block

Tags:

emacs

org-mode

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.

like image 910
armandino Avatar asked Oct 19 '14 04:10

armandino


1 Answers

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.

like image 190
Tobias Avatar answered Oct 11 '22 12:10

Tobias