Tuesday, September 8, 2009

Directional window movement in emacs

One thing I sometimes miss about the text editor Brief, which I stopped using a decade ago, is being able to move between windows easily by pressing a function key and then an arrow key to switch to a window in that direction.

In emacs I only knew how to move between windows using `other-window', mapped to C-x o and that only cycles around the windows, and if you have a few windows open and possibly you're also editing the mini-buffer, that's quite a round trip.

I just learned about `M-x windmove-default-keybindings', which binds a set of commands that do exactly the kind of directional movement I'm talking about (`windmove-right', `windmove-up' and so on) to the cursor keys (with shift key held).


Alex said...

Heh, Brief was one of the first proper programmers editors I ever used. Fantastic little program.

Great find, window navigation has always been a bit of a pain point for me on Emacs.

Unknown said...

i'm assuming then that you know that you can put:


in your .emacs and get those keybindings by default without having to type M-x win... ?

If not, then you're welcome :)

and for info on how to bind it to some key other than shift (some people use shift-selection):


Justin said...

Yes, I have added it to my .emacs perhaps I should have mentioned that ;-)