1

In evil mode, I would like C-i not to work as a tab key, which is the default behavior in Emacs. Also, I would not have the default vi behavior simulated in Emacs evil by evil-jump-forward, but instead I would like to have C-i work as the scroll-down-command.

Then, since C-i is mapped to <tab> by default, and I would like <tab> work as the usual indent-for-tab-command, I need to bind <tab> also. Here is a minimal setup:

(setq package-load-list
      '((evil t)
        (undo-tree t)
        (goto-chg t)))

(package-initialize)
(require 'evil)
(evil-mode 1)
(define-key evil-normal-state-map (kbd "C-i") 'scroll-down-command)
(define-key evil-normal-state-map (kbd "<tab>") 'indent-for-tab-command)

The problem now is that this seems to confuse org-mode. I think <tab> in org-mode only works correctly if <tab> is not bound, in that case org-mode will rebind it locally to org-cycle.

So now I am not able to expand subtrees in org-mode. In fact, in org-mode the <tab> key is bound to indent-for-tab-command instead of the desired org-cycle command. How to solve this problem?

Note that the solution provided in Emacs, org-mode, evil-mode - TAB key not working does not work, since I rebind the <tab> key.

2

It's not 100% clear what you want the tab key to do when you're in org-mode.

What you have done is to bind tab in evil's "global" normal-state keymap. If you're in normal state in an org buffer, tab will do what you bound it to do, not to the default org-cycle.

If you want tab to invoke org-cycle in org buffers when you're in normal state, you can:

(evil-define-key 'normal org-mode-map (kbd "<tab>") #'org-cycle)
  • Great! This works perfectly. Nice to learn about the evil-define-key function. – Håkon Hægland Oct 28 '16 at 18:59

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.