When you have Emacs split into multiple windows, how do you move your cursor between windows? How do you move the windows around?
Update (27 Jan 2015): You may want to skip the post below and use ace-window. I plan to use it rather than my solution below. Also, see Sacha Chua’s video on window management, including using ace-window.
Moving the cursor between windows
You can use
C-x o to move the cursor to the “other” window. That works great when you only have two windows:
C-x o toggles between them.
When you have more windows,
C-x o moves to the next window in top-to-bottom, left-to-right order. So if you have five windows, for example, you have to go to the “other” window up to four times to move to each of the windows.
The cursor is in the A window. Repeatedly executing
C-x o will move the cursor to C, B, and D.
There are more direct commands:
You might map these to Control or Alt plus the arrow keys to have a memorable key sequence to navigate windows. However, such keybindings may conflict with existing keybindings, particularly in
You can move windows around with the buffer-move. (Technically the windows stay fixed and the buffer contents moves around.)
Super and Hyper keys
Since the various Control arrow keys and Alt arrow keys are spoken for in my configuration, I thought I’d create Super and Hyper keys so that Super-up would map to
Several articles recommend mapping the Windows key to Super and the Menu key to Hyper on Windows. The former is a poor choice because so many of the Windows key combinations are already used by the OS. I did get the latter to work by adding the following to the branch of my
init.el that runs on Windows.
(setq w32-pass-apps-to-system nil w32-apps-modifier 'hyper) (global-set-key (kbd "<H-up>") 'windmove-up) (global-set-key (kbd "<H-down>") 'windmove-down) (global-set-key (kbd "<H-left>") 'windmove-left) (global-set-key (kbd "<H-right>") 'windmove-right)
I haven’t figured out yet how to make Super or Hyper keys work on Linux. Suggestions for setting up Super and Hyper on Linux or Windows would be much appreciated.