M-x all-things-emacs

Quick Tip: Easier Window Switching in Emacs

May 1st, 2008 by Rob Christie · 9 Comments

I ran across this thread on easier window switching within emacs using the windmove-xxx commands on gnu.emacs.help a few days ago. It’s always nice to find out about commands I didn’t know about… kinda like C-x M-c M-butterfly. I have always used C-x o and C-x b to move between windows and buffers, but my work monitor is large enough to allow me to split my frame into four windows. Using C-x o to move around has been somewhat of an annoyance. The windmove commands allow you to move up, down, left, and right between windows using a prefix key and the arrows on your keyboard. I have added the following to my .emacs:

(windmove-default-keybindings 'meta)

If you invoke the command without an argument then shift is used as the prefix. I also had to place this below the turning on of pc-selection-mode because it also sets the M-up, M-down, M-left, and M-right keys.

Tags: quick · tips

9 responses so far ↓

  • 1 Luke Hoersten // May 1, 2008 at 7:23 pm

    I was unable to get this to work on Mac OS X. I’m going to try Ubuntu when I get home. Any hints for Mac OS X? I’m new to it.

  • 2 Knusper // May 1, 2008 at 8:22 pm

    Ah… Nice trick… :)

  • 3 Rob Christie // May 1, 2008 at 9:36 pm

    @Luke – I am using carbon emacs on Mac OS X. What version are you using?

  • 4 Seung-Cheol Jung // May 2, 2008 at 1:19 am

    It works perfectly for me on the zenitani’s carbon emacs.

  • 5 Jia // May 6, 2008 at 12:48 pm

    This is a nice one. Thanks a lot.

  • 6 Andy Norris // May 6, 2008 at 6:20 pm

    I’m an Emacs heretic, and defined a whole mess of CUA-style bindings (C-o for find-file, C-s for save-buffer, etc.), so my arrow keys are spoken for with things like M-left as backward-word.

    But I’ve found C-n for other-window and C-b for switch-to-buffer to be quite nice in my 3 window setup.

  • 7 Michael // May 6, 2008 at 8:46 pm

    Works like a champ in Aquamacs

  • 8 Cheezwizard // May 8, 2008 at 10:49 pm

    Does this work in XEMACS

  • 9 Ustun // May 10, 2008 at 11:40 am

    brilliant!

Leave a Comment