7

When I edit a source block it comes out in the org-mode buffer like this:

- Item 1
  Text indented two spaces here under list entry

  #+BEGIN_SRC ruby
class Name
end
  #+END_SRC

But it should be indented like this:

- Item 1
  Text indented two spaces here under list entry

  #+BEGIN_SRC ruby
  class Name
  end
  #+END_SRC

How do I need to configure org-mode to solve this issue?

4
  • What are your values for 'org-src-preserve-indentation' and 'org-edit-src-content-indentation'? Feb 22, 2015 at 12:12
  • (setq org-src-preserve-indentation t org-edit-src-content-indentation 2) Feb 22, 2015 at 16:15
  • @TadAshlock, thanks for your hint, I changed my setting, (setq org-src-peserve-indentation nil org-edit-src-content-indentation 0) . this solved my problem. Feb 22, 2015 at 16:22
  • Worth mentioning, the manual page on this: orgmode.org/manual/Editing-source-code.html
    – Malabarba
    Apr 12, 2015 at 20:14

2 Answers 2

8

This solved my problem.

(setq org-src-preserve-indentation nil 
      org-edit-src-content-indentation 0)
1

You can use C-c' to edit the block using the ruby-mode (or any other mode you specified for babel). Now you can indent the whole buffer according to the ruby-mode. Leave using C-c' again and your block should be indented now.

You could also create a function or a macro to run those steps for you, to automatize the process, if you wish.

3
  • I did edit babel source code with C-c '. Feb 22, 2015 at 16:17
  • Ops, sorry, I didn't imply that
    – Jesse
    Feb 23, 2015 at 15:06
  • C-c' is freakin AWESOME Jan 31, 2017 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.