3

Running emacs 25.2.2, general, evil and markdown-mode installed from MELPA.

The problem is when I hit TAB on a heading in a markdown file, it does not cycle visibility of content.

C-h k TAB shows it is assigned to evil-jump-forward.

So, in my init.el, I added:

(general-def 'markdown-mode-map
  "TAB" 'markdown-cycle)

But still TAB is assigned to evil-jump-forward.

How do I assign TAB to markdown-cycle in markdown-mode?

Moreover, can I assign it such that only when the cursor is on a heading, it is assigned to markdown-cycle but at other locations, it is assigned to evil-jump-forward?

1
  • This doesn't help with your additional question and no idea whether this solves it, but you should remove the ' before markdown-mode-map when using general-def
    – EFLS
    Aug 22, 2018 at 13:50

2 Answers 2

1

I've been looking into this as well. The reason your attempt isn't working, is because of evil and the way it binds keys to a higher level keymap (as far as I understand the matter).

Anyways, you can bind directly to the corresponding evil state you want to use the key in.

The following should do the trick:

(evil-define-key 'normal markdown-mode-map
       (kbd "<tab>") 'markdown-cycle)

(You might need to hit tab twice if there are no subheadings.)

The package evil-markdown provides much more complete integration with evil. Not on MELPA, unfortunately, so you'll have to install it manually. Check it out on https://github.com/Somelauw/evil-markdown.

0

Supporting the previous answer, I think <tab> needs to be replaced with TAB. For me, snippet in above answer didn't work but the following snippet worked:

(evil-define-key 'normal markdown-mode-map
  (kbd "TAB") 'markdown-cycle)

All the change is that I have used TAB instead of <tab>.

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.