1

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)

1
  • 3
    This has been answered here.
    – Anonymous
    May 24, 2011 at 0:25

5 Answers 5

4

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!

2

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

1

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
4
  • I thought what you did, but he actually did mean windows.
    – Anonymous
    May 24, 2011 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, 2011 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, 2011 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, 2011 at 17:14
1

I have these lines in my init.el:

;; Use shift key to move between various split windows

(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))

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

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .