Tabyasnippet 的键绑定通常会覆盖其他有用的键。
有没有办法禁用TabYasnippet 的绑定以启用其他Tab用途?
这些将删除 yasnippet 的键绑定:
(define-key yas-minor-mode-map [(tab)] nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
应该管用。或者您可以绑定tab
到另一个命令。
我参加聚会迟到了,但在这个问题中得到了公认的答案……没有用。
试验了一下,终于找到了解决办法。认为我应该提供一个有效的答案:
;; 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)
(use-package yasnippet
:demand t
:bind (:map yas-minor-mode-map
("TAB" . nil)
("<tab>" . nil))
:config
(yas-global-mode))
(setq yas-minor-mode-map ;This MUST before (require 'yasnippet)
(let ((map (make-sparse-keymap)))
(define-key map (kbd "M-i") 'yas-expand)
(define-key map "\C-c&\C-n" 'yas-new-snippet)
(define-key map "\C-c&\C-v" 'yas-visit-snippet-file)
map))
(require 'yasnippet)