As I mentioned in my winner-mode post, I recently configured Emacs to start with a frame-width of 162 columns. I’ve also added a call to split-window-right
in my init.el
to get the two columns of windows that I prefer. This introduces the problem of how to navigate between windows easily. If there’s only two windows, the usual 【Ctrl+x o】 works nicely but it quickly becomes cumbersome when there are 3 or more windows in the selected frame.
It turns out that there is a really nice solution to this although it’s a bit hard to find. If you add
(windmove-default-keybindings)
to your .emacs
or init.el
file, you can move between windows with the 【Shift+→】/ 【Shift+←】/ 【Shift+↓】 / 【Shift+↑】 key sequences. You can change the modifier by specifying a different one as the argument to windmove-default-keybindings
.
If, like me, you’re a heavy org-mode
user, you’ll find that these key bindings won’t work in org-mode
buffers because org-mode
takes them over. Happily you can solve this by adding the line
(setq org-replace-disputed-keys t)
to your .emacs
or init.el
. This will cause org-mode
to replace the shift-arrow keys with others for its operations. You can also tell org-mode
to replace the windmove
keys only when the point is not at a place when org-mode
would want to use them as explained in the Org Mode Manual.
All this may not sound like much but they are a huge win for me. I can have several windows open in a frame and still move among them easily. Another demonstration of the power and configurability of Emacs.
Update: windmove-default-bindings
→ windmove-default-keybindings