9

I'm using gdb-many-windows, which contains five windows to switch between. Is there a shortcut I can use to get to a specific window?

Rose Perrone
  • 61,572
  • 58
  • 208
  • 243

5 Answers5

8

You probably already know that C-x o gets you to the next window. You can extend this to go to any arbitrary window with C-u <windowoffset> C-x o.

So, you can use C-u 2 C-x o to switch to the second window ahead of your current one.

This wraps around the window list (so in your case of 5 windows you could do C-u 4 c-x o to go back one.

You can also use negative numbers as well to go backwards.

Lastly, it takes a bit more setup, but Thomas's suggestion to use WindMove is very useful. It wasn't configured by default for me to any useful key binding. I add the following snippet to my (mac) .emacs file, whch lets me switch windows via control-arrow (you will need to reload .emacs by starting up or via 'M-x load-file')

(global-set-key (kbd "M-[ 5 d") 'windmove-left)
(global-set-key (kbd "M-[ 5 c") 'windmove-right)
(global-set-key (kbd "M-[ 5 a") 'windmove-up)
(global-set-key (kbd "M-[ 5 b") 'windmove-down)
Michael Chinen
  • 17,737
  • 5
  • 33
  • 45
5

Some people find WindMove more convenient than C-x o. It allows you to navigate between windows using Shift + arrow keys.

Thomas
  • 17,016
  • 4
  • 46
  • 70
  • Does Terminal 2.2.1 not support modified arrow keys? – Rose Perrone Feb 05 '12 at 05:39
  • I don't use Macs, but you could try to type "CTRL-v right-arrow" and "CTRL-v Shift-right-arrow" in bash and see if it produces different escape sequences. If not, you could still use WindMove by binding the respective functions to different keyboard shortcuts, of course. – Thomas Feb 06 '12 at 01:26
1

Possibly useful links:

http://www.emacswiki.org/emacs/WindowNumberingMode

http://www.emacswiki.org/emacs/NumberedWindows

Edit: If you decide to use WindowNumberingMode (that's what I use) you might find it useful to pin buffers to windows (so, for instance, Meta-1 switches to the buffer you expect it to switch to, not just the first window). One way of pinning is described in Pin Emacs buffers to windows (for cscope).

Community
  • 1
  • 1
Miron Brezuleanu
  • 2,989
  • 2
  • 22
  • 33
1

Window switching is so important in emacs, I have these settings.(Still feel these are not good enough).. may help someone else..

(global-set-key "\M-t" 'other-window)   ;; was transpose words
(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 t
kindahero
  • 5,817
  • 3
  • 25
  • 32
0

I use switch-window.el. You can choose a window by visual way with 'switch-window'.

Image of using switch-window

syohex
  • 2,293
  • 17
  • 16