Imagine I have following four windows in Emacs:

Emacs session with four windows

Window 1 is a shell window (M-x shell). Windows 2, 3, and 4 are normal windows with files open. Evil mode is enabled.

If I am the shell window, how can I go to any other window (2, 3, 4) without using the mouse?

The obvious choice is to use, for example, CTRL-w j to go from 1 to 2, but it does not work.

Emacs version: GNU Emacs 27.1 (build 1, x86_64-apple-darwin19.6.0, Carbon Version 162 AppKit 1894.6) of 2020-10-06 OS: MacOS Catalina Version 10.15.7

1 Answer 1


The evil keybindings seem not to work for me in every major mode as either.

What might help is to add the evil-collection package.

But what I did to really make sure that my keybinding for switching windows is:

 (with-eval-after-load 'term
  (define-key term-raw-map (kbd "C-<left>") 'evil-window-left)
  (define-key term-raw-map (kbd "C-<right>") 'evil-window-right)
  (define-key term-raw-map (kbd "C-<up>") 'evil-window-up)
  (define-key term-raw-map (kbd "C-<down>") 'evil-window-down))

The "with-eval-after-load" part seems to do it.

You might want to swap "term" for "shell" in your case though. This might not be the most elegant way to do this, but it worked for me beautifully.

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.