To make M-q
execute save-buffers-kill-terminal
by default, you will want to change M-q
's global keybinding:
(global-set-key (kbd "M-q") 'save-buffers-kill-terminal)
But, remember, global keybindings are overridden by mode-specific bindings. In fact, we are going to take advantage of this:
To make a special exception for M-q
in Evil-mode when inserting, add a specific keybinding for fill-paragraph
into evil-insert-state's keybinding "map":
(define-key evil-insert-state-map (kbd "M-q") 'fill-paragraph)
This one will override the global binding, and will only work in Evil-mode's insert state.
Adding those two lines to your .emacs configuration file should do the trick.