Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

gdb

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?

like image 969
Rose Perrone Avatar asked Feb 04 '12 01:02

Rose Perrone


People also ask

How do I switch between screens in Emacs?

To select a different window, click with Mouse-1 on its mode line. With the keyboard, you can switch windows by typing C-x o ( other-window ).

How do I navigate between buffers in Emacs?

To move between the buffers, type C-x b. Emacs shows you a default buffer name. Press Enter if that's the buffer you want, or type the first few characters of the correct buffer name and press Tab. Emacs fills in the rest of the name.

How do I open a second window in Emacs?

To open a new frame, select Make New Frame from the Files menu or press C-x 5 2 (for make-frame). Emacs makes a new frame containing the current buffer and puts it on top of the current frame.

What are buffers in Emacs?

Buffers in Emacs editing are objects that have distinct names and hold text that can be edited. Buffers appear to Lisp programs as a special data type. You can think of the contents of a buffer as a string that you can extend; insertions and deletions may occur in any part of the buffer.


4 Answers

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)
like image 92
Michael Chinen Avatar answered Oct 04 '22 19:10

Michael Chinen


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

like image 45
Thomas Avatar answered Oct 04 '22 19:10

Thomas


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

like image 33
Miron Brezuleanu Avatar answered Oct 04 '22 19:10

Miron Brezuleanu


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
like image 38
kindahero Avatar answered Oct 04 '22 19:10

kindahero