Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unset 'Tab' binding for yasnippet?

The Tab keybinding of yasnippet often overwrites other useful keys.

Is there a way to disable Tab binding of Yasnippet to enable other Tab usage?

like image 268
Hanfei Sun Avatar asked Dec 28 '12 08:12

Hanfei Sun


3 Answers

These will remove yasnippet's key binding:

(define-key yas-minor-mode-map [(tab)] nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)

Should work. Or you can bind tab to another command.

like image 165
Saddle Point Avatar answered Nov 10 '22 17:11

Saddle Point


I'm late for the party but came upon the accepted answer in this question which... didn't work.

Experimented a bit and finally found a solution. Thought I should contribute an answer that does work:

;; It is crucial you first activate yasnippet's global mode.
(yas/global-mode 1)

;; The following is optional.
(define-key yas-minor-mode-map [backtab]     'yas-expand)

;; Strangely, just redefining one of the variations below won't work.
;; All rebinds seem to be needed.
(define-key yas-minor-mode-map [(tab)]        nil)
(define-key yas-minor-mode-map (kbd "TAB")    nil)
(define-key yas-minor-mode-map (kbd "<tab>")  nil)
like image 26
miguelg Avatar answered Nov 10 '22 19:11

miguelg


With use-package:

(use-package yasnippet
  :demand t
  :bind (:map yas-minor-mode-map
         ("TAB" . nil)
         ("<tab>" . nil))
  :config
  (yas-global-mode))
like image 2
Radon Rosborough Avatar answered Nov 10 '22 18:11

Radon Rosborough