Editing src blocks directly in org file is nice but you cannot benefit from all minor modes that would be enabled in dedicated code edit buffer, more then that for a big babel file the performance struggles. Usually I forget to do this additional keystroke and end up editing in org. Is there any out-of-the-box option or simple workaround this can be made automatic - e.g. whenever I hit edit command the buffer is opened automatically and gets activated with all input continuing there?

p.s. I'm using evil - one thing that came to my mind was capturing some evil-into-insert-mode-hook and checking if I'm inside a src block, but this is does not cover all cases of course

1 Answer 1


Ok, figured that out on my own - at least, for evil:

    (add-hook 'org-mode-hook (lambda() 
        (make-local-variable 'evil-insert-state-entry-hook) ;; making this hook act only locally in the buffer where org-mode-hook has been called
        (add-hook 'evil-insert-state-entry-hook #'org-edit-src-code)))
  • You should be able to accept your own answer by now.
    – NickD
    Commented Feb 20 at 12:01

Your Answer

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

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