I want to bind evil leader keys for org-edit-src-save and org-edit-src-exit in org-src-mode. And I have:

(evil-leader/set-key-for-mode 'org-src-mode
  "s" 'org-edit-src-save
  "'" 'org-edit-src-exit)

But it doesn't work. What's wrong with my code?


When we use org-src-mode, the major mode is changed to the language we are editing.

So 'org-src-mode should change to the language mode or you can set it globally. For example:

#+BEGIN_SRC emacs-lisp

(C-c ') then the major mode in new buffer is emacs-lisp-mode, not org-src-mode. So you should set evil-leader keys for emacs-lisp-mode, such as:

(evil-leader/set-key-for-mode 'emacs-lisp-mode
  "s" 'org-edit-src-save
  "'" 'org-edit-src-exit)

or, set it globally by:

  "s" 'org-edit-src-save
  "'" 'org-edit-src-exit)
| improve this answer | |
  • Welcome. I have tried to improve the language of the post. I hope I have kept your meaning. – Andrew Swann Aug 22 '16 at 6:02

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.