Rose Perrone
Rose Perrone

Reputation: 63576

Is there a better way to switch between multiple windows in emacs gdb besides C-x-o?

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?

Upvotes: 9

Views: 1566

Answers (5)

Michael Chinen
Michael Chinen

Reputation: 18717

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)

Upvotes: 8

kindahero
kindahero

Reputation: 5867

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

Upvotes: 1

Miron Brezuleanu
Miron Brezuleanu

Reputation: 3060

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).

Upvotes: 1

syohex
syohex

Reputation: 2303

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

Image of using switch-window

Upvotes: 0

Thomas
Thomas

Reputation: 17422

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

Upvotes: 5

Related Questions