I have changed the keybindings for yasnippet and autocomplete so that I can use tab for indentation anywhere in a line without accidentally autocompleting or inserting a snippet.

I have this in my init.el


(require 'auto-complete-config)
(define-key ac-mode-map (kbd "TAB") nil)
(define-key ac-completing-map (kbd "TAB") nil)
(define-key ac-completing-map [tab] nil)

(ac-set-trigger-key "`") ;; sets the auto-complete key   

(require 'yasnippet)
  (dot-emacs "elpa/yasnippet/snippets"))

;; Remove Yasnippet's default tab key binding            
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
;; Set Yasnippet's key binding to shift+tab              
(define-key yas-minor-mode-map (kbd "§") 'yas-expand)

This works for most emacs modes, however when I use one particular mode (vhdl-mode) the yasnippet key bind § works as expected but ` does not work for auto-complete and it resets to the default tab key for autocomplete.

This means when I go through my code using tab to indent or un-indent parts of it random words are auto-completed.

2 Answers 2


vhdl-mode binds tab to vhdl-electric-tab, which calls hippie-expand in most cases. That would explain unexpected/unwanted completions. You'll need to overwrite this in the vhdl-mode map.

(require 'vhdl-mode)
(define-key vhdl-mode-map "\t" nil)

I haven't looked at the source-code, but vhdl-mode is probably resetting the keybindings for auto-complete by itself. Does it work if you manually redefine them again after vhdl-mode loads?

(defun my-redefine-auto-complete-keys ()
  (define-key ac-mode-map (kbd "TAB") nil)
  (define-key ac-completing-map (kbd "TAB") nil)
  (define-key ac-completing-map [tab] nil)
  (ac-set-trigger-key "`"))

(add-hook 'vhdl-mode-hook 'my-redefine-auto-complete-keys)
  • 1
    Nope, that didn't work, I just noticed when I start emacs in vhdl-mode I get the message Package assoc is obsolete! in the buffer. Maybe this is the cause. Sep 29, 2016 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.