0

I've keybinded &é"'... to selecting windows:

  (global-set-key (kbd "²") 'select-window-0)
  (global-set-key (kbd "&") 'select-window-1)
  (global-set-key (kbd "é") 'select-window-2)
  (global-set-key (kbd "\"") 'select-window-3)
  (global-set-key (kbd "\'") 'select-window-4)
  (global-set-key (kbd "(") 'select-window-5)
  (global-set-key (kbd "-") 'select-window-6)
  (global-set-key (kbd "è") 'select-window-7)
  (global-set-key (kbd "_") 'select-window-8)
  (global-set-key (kbd "ç") 'select-window-9)

However now everytime I need to type something in the minibuffer that contains those characters it tries to select those windows instead. How would I limit the scope of these keybinds only to the normal mode in buffers that are not the minibuffer ? Also when I'm in insert mode I would like those keybinds to just insert the characters.

1

I'm just assuming that you are using Evil and have edited the tags accordingly.

If you don't want to globally change key, you will need to use define-key with the right keymap. This introduces one more difficulty, the keymap must be defined when running your code:

(with-eval-after-load 'evil
  (define-key evil-normal-state-map (kbd "²") 'select-window-0)
  (define-key evil-normal-state-map (kbd "&") 'select-window-1)
  (define-key evil-normal-state-map (kbd "é") 'select-window-2)
  (define-key evil-normal-state-map (kbd "\"") 'select-window-3)
  (define-key evil-normal-state-map (kbd "\'") 'select-window-4)
  (define-key evil-normal-state-map (kbd "(") 'select-window-5)
  (define-key evil-normal-state-map (kbd "-") 'select-window-6)
  (define-key evil-normal-state-map (kbd "è") 'select-window-7)
  (define-key evil-normal-state-map (kbd "_") 'select-window-8)
  (define-key evil-normal-state-map (kbd "ç") 'select-window-9))

In the absence of with-eval-after-load, use (eval-after-load 'evil '(progn ...)).

| improve this answer | |

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.