11

Possible Duplicate:
How can I more easily switch between buffers in Emacs?

While working with emacs I tend to keep many open windows. Unfortunately using M-x other-window is quite annoying. So far I have set up keyboard shortcut in my .emacs file: (global-set-key (quote [backtab]) (quote other-window)). That makes things a bit easier but I am looking for equivalents of commands next-buffer and previus-buffer that can be applied to windows.

Community
  • 1
  • 1
Karol
  • 145
  • 1
  • 5
  • I have M-x other-window on F11 and twice M-x other-window on F12. In 3-windowed setup that I use it works as 'next' and 'previous'. – Boris Stitnicky May 27 '12 at 15:21
  • @BorisStitnicky: I usually have 8 windows. This may sound a bit odd but that`s my taste ;) – Karol May 27 '12 at 15:34
  • possible duplicate of [Changing window faster in Emacs (or repeating last shortcut with a single strike)](http://stackoverflow.com/questions/5046597/changing-window-faster-in-emacs-or-repeating-last-shortcut-with-a-single-strike) and [Emacs, switch active window](http://stackoverflow.com/questions/91071/emacs-switch-active-window) and [How to switch between visible buffers in emacs?](http://stackoverflow.com/questions/4671819/how-to-switch-between-visible-buffers-in-emacs) and [Better window navigation in Emacs?](http://stackoverflow.com/questions/4858958/better-window-navigation-in-emacs) – phils May 27 '12 at 22:40
  • 7
    The question was closed (correctly) but reason: Possible Duplicate: [How can I more easily switch between buffers in Emacs?](http://stackoverflow.com/questions/7394289/how-can-i-more-easily-switch-between-buffers-in-emacs) is incorrect. Windows and buffers are two distinct things in emacs (windows are kind of viewports of buffers). Comment from @phils states better explanation of closing this question. – Karol May 28 '12 at 17:25

1 Answers1

20

Add the following to your .emacs

(windmove-default-keybindings)
(setq windmove-wrap-around t)

Then you'll be able to switch between windows with Shift+{left,up,down,right} arrows. Shift modifier is a parameter to windmove-default-keybindings, so you can choose another one.

You may want to activate a winner-mode. It's a minor mode which remembers your window configurations and you can go to the previous/next configuration using winner-undo or winner-redo.

Oleg Pavliv
  • 20,462
  • 7
  • 59
  • 75
  • 1
    That's exactly what I was looking for. More information about the solution can be found on [emacs wiki](http://emacswiki.org/emacs/WindMove) – Karol May 27 '12 at 15:47
  • _For any Spacemacs users:_ the suggested bit of code should be put inside the `dotspacemacs/user-init` function in your `.spacemacs` file. – Benjamin R Feb 11 '19 at 14:28