Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

C-xo moves you to the next window in emacs, how do you move to the previous window?

I sometimes have up to 10 windows open and it would be great to move in either direction.

Also is there a way to jump to a specific window by number? (jump to the 3rd window for example)

share|improve this question

migrated from May 25 '11 at 5:39

This question came from our site for professional and enthusiast programmers.

This has been answered here. – Anonymous May 24 '11 at 0:25

How about this:

(defun other-window-backwards (count)
  (interactive "p")
  (other-window (- count)))

(global-set-key [(control meta prior)] 'other-window-backwards)
(global-set-key [(control meta next)]  'other-window)

Then use C-M-prior (Page Up) to move to previous window, C-M-next (Page Down). Flavor bindings to suit!

share|improve this answer

you mean buffers?? if so there are next-buffer and previos-buffer functions which perform Switch to the next/previous buffer in cyclic order.

Edit: with spong answer. I use windmove for window switching.

(windmove-default-keybindings) ;; Shift+direction  
(global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1))) ;; back one
(global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 2))) ;; forward two
share|improve this answer
I thought what you did, but he actually did mean windows. – Anonymous May 24 '11 at 2:44
@andrewdski Since he said 10 windows I get that thought. as I go more than 4 windows in a frame it gets unmanageable. I should have written as a comment to question instead of an answer. – kindahero May 24 '11 at 5:58
@kindahero, Yeah 10 windows does seem pretty crazy! Maybe we should have simply said "screen shot or you lie"! :) – Anonymous May 24 '11 at 14:14
Ok, maybe I exaggerate, but right now I have 6 open. It is the curse of having a large vertical monitor. You just have to fully use it. Anyway, I remaped C-x , and C-x . to forward and backward and that works great. (oh and C-x m and C-x / for double moves) Thanks! – RobKohr May 24 '11 at 17:14

I have these lines in my init.el:

;; Use shift key to move between various split windows

(when (fboundp 'windmove-default-keybindings)

This helps me to move between various split windows by using Shift+ arrow keys.

share|improve this answer

You can give the command C-x o an argument of -1, like so: C-u -1 C-x o

That will take you to the previous window

Also to get 3 windows back use: C-u -3 C-x o

share|improve this answer

Bart (and others) have given correct answers for your exact question. You can also look at windmove which should came packaged into the latest Emacsen.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.