3

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?

  • What are your values for 'org-src-preserve-indentation' and 'org-edit-src-content-indentation'? – Tad Ashlock Feb 22 '15 at 12:12
  • (setq org-src-preserve-indentation t org-edit-src-content-indentation 2) – stardiviner Feb 22 '15 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. – stardiviner Feb 22 '15 at 16:22
  • Worth mentioning, the manual page on this: orgmode.org/manual/Editing-source-code.html – Malabarba Apr 12 '15 at 20:14
4

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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