tags:

views:

606

answers:

4

other-window advances me to the next frame in my frame list. But I also want a way to advance me to the previous frame.

Emacs has next-buffer and previous-buffer, but not a next-window, previous-window. Just other-window.

+6  A: 

Put this in your .emacs, and bind it to whatever key you like

(defun back-window ()
  (interactive)
  (other-window -1))
smoofra
+11  A: 

Provide a negative argument with "C-u -" ("Control+U" then "minus")

  • Move to previous window: C-u - C-x o
  • Move to previous frame: C-u - C-x 5 o

From code, (other-window -1) or (other-frame -1) will do the same thing.

Check out the help for the key you want to reverse (e.g. C-h k C-x o to show help for C-x o) and if it says "A negative argument..." you know you can use "C-u -".

Matt Curtis
A bit strange but when I have a layout 2x3 windows with windows 1-6 using `C-x o` moves from 3 to 4, but in 4 using `C-u - C-x o` moves from 4 to 2. What would move me from 4 to 3 ?
Zitrax
+1  A: 

Different from what you asked for, but the windmove package lets you move between windows according to their relative screen locations, which can be much easier than repeatedly doing C-x o.

fivebells
A: 

Instead of C-u -, you can also give a negative prefix argument with just M-- (Meta-Minus) , i.e. switch to previous window with M-- C-x o.

Florian Jenn