Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs move around split windows in a specified direction?

Tags:

In Terminal Emacs (no mouse), I'm using split windows to work with multiple buffers at the same time. I'm finding moving between the split windows much more painful than how I do it in Vim. Reading the documentation it looks like I'm doing it correctly (C-x o), but that just cycles around the windows in a clockwise direction. If I move to an adjacent window to make a quick edit, I need to hit C-x o a few times before I'm back where I was. Sometimes I accidentally press it too many times in a hurry and have to cycle all the way back through the windows again.

Far from install yet-another-external-package, is there any way I can just either move directly to a window (by, say, a number), or at least cycle around the windows in the opposite direction?

In Vim C-w C-w is like C-x o in Emacs, but there's also C-w ARROW to move in a specified direction... something like that? :)

like image 300
d11wtq Avatar asked May 17 '13 11:05

d11wtq


People also ask

How do I move windows in Emacs?

With the keyboard, you can switch windows by typing C-x o ( other-window ). That is an o , for `other', not a zero. When there are more than two windows, this command moves through all the windows in a cyclic order, generally top to bottom and left to right.

How do I split a window vertically in Emacs?

You can split a window horizontally or vertically by clicking C-Mouse-2 in the mode line or the scroll bar.

How do I open a new 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. These lines set up sizes for the width and height of Emacs frames.

How do I change the size of my emacs window?

Type C-c + to enlarge the window. Then hit + or - repeatedly to enlarge/shrink the window. Any other key ends the resize operation.


2 Answers

Add this to your init file:

(windmove-default-keybindings) 

Then you can use SHIFT+arrow to move to the next adjacent window in the specified direction.

You can specify a different modifier if you prefer, by passing an argument (defaults to 'shift).

Or just bind whatever you like to these functions:

  • windmove-up
  • windmove-down
  • windmove-left
  • windmove-right

You can also add FrameMove to the mix, to make this work transparently across multiple frames.

For numbered window navigation, there's switch-window.el.

like image 162
phils Avatar answered Sep 20 '22 21:09

phils


Add this to your init file (e.g. ~/.emacs):

(windmove-default-keybindings) 

Then do SHIFT+arrow to move to the window in that direction.

like image 41
jameshfisher Avatar answered Sep 22 '22 21:09

jameshfisher