15

I was reading the the documentation for Yasnippet mode, when I came to the section where the trigger key is defined:

It seems like Yasnippet minor mode defines the TAB key to run yas-expand using:

(define-key yas-minor-mode-map (kbd "<tab>") 'yas-expand)
(define-key yas-minor-mode-map (kbd "TAB") 'yas-expand)

What is the difference between <tab> and TAB? (I tried to google this but I could not find a clear description)

9

Although Emacs usually translates <tab> (the single key) to TAB (C-i), you can bind <tab> and TAB to different things:

(global-set-key (kbd "<tab>") #'proced)
(global-set-key (kbd "TAB") #'indent-for-tab-command)
  • 2
    I see, but why do Yasnippet need to define both <tab> and TAB? – Håkon Hægland Feb 27 '15 at 9:48
  • 3
    @HåkonHægland if you happen to bind them to different commands on the global-map, emacs stops translating one to the other (even on minor mode maps), so yasnippet bind both just in case. – Malabarba Feb 27 '15 at 10:14
  • 1
    @Malabarba So if you define both <tab> and TAB, the only way to run the command associated with TAB is to type C-i ? – Håkon Hægland Feb 27 '15 at 10:38
  • 2
    If you bind <tab> to a different command than what you bind TAB to, then what you get when you hit the "Tab" key depends on which/what it sends to Emacs. If it sends C-i (aka TAB) then you get the TAB binding. If it sends <tab> then you get its binding. (And yes, you can always hit C-i to get the TAB binding.) – Drew Feb 27 '15 at 15:57
  • 1
    More historical information about the different TAB keys are given by StreakyCobra in this spacemacs github issue. You may want to include some of that information in your answer. – Håkon Hægland Oct 28 '16 at 9:16

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.