• Stars
    star
    968
  • Rank 47,266 (Top 1.0 %)
  • Language
    Emacs Lisp
  • Created over 10 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quickly switch windows in Emacs

ace-window

GNU ELPA MELPA MELPA Stable

GNU Emacs package for selecting a window to switch to

What and why

I'm sure you're aware of the other-window command. While it's great for two windows, it quickly loses its value when there are more windows. You need to call it many times, and since it's not easily predictable, you have to check each time if you're in the window that you wanted.

Another approach is to use windmove-left, windmove-up, etc. These are fast and predictable. Their disadvantage is that they need 4 key bindings. The default ones are shift+arrows, which are hard to reach.

This package aims to take the speed and predictability of windmove and pack it into a single key binding, similar to other-window.

Setup

Just assign ace-window to a short key binding, as switching windows is a common task. I suggest M-o, as it's short and not bound to anything important in the default Emacs.

Usage

When there are two windows, ace-window will call other-window (unless aw-dispatch-always is set non-nil). If there are more, each window will have the first character of its window label highlighted at the upper left of the window. Pressing that character will either switch to that window or filter to the next character needed to select a specific window. Note that, unlike ace-jump-mode, the position of point will not be changed, i.e. the same behavior as that of other-window.

A special character defined by aw-make-frame-char (default = z) means create a new frame and use its window as the target. The new frame's location is set relative to the prior selected frame's location and given by aw-frame-offset. The new frame's size is given by aw-frame-size. See their documentation strings for more information.

The windows are ordered top-down, left-to-right. This means that if you remember your window layouts, you can switch windows without even looking at the leading char. For instance, the top left window will always be 1 (or a if you use letters for window characters).

ace-window works across multiple frames, as you can see from the in-action gif.

Swap and delete window

  • You can swap windows by calling ace-window with a prefix argument C-u.

  • You can delete the selected window by calling ace-window with a double prefix argument, i.e. C-u C-u.

Change the action midway

You can also start by calling ace-window and then decide to switch the action to delete or swap etc. By default the bindings are:

  • x - delete window
  • m - swap windows
  • M - move window
  • c - copy window
  • j - select buffer
  • n - select the previous window
  • u - select buffer in the other window
  • c - split window fairly, either vertically or horizontally
  • v - split window vertically
  • b - split window horizontally
  • o - maximize current window
  • ? - show these command bindings

For proper operation, these keys must not be in aw-keys. Additionally, if you want these keys to work with fewer than three windows, you need to have aw-dispatch-always set to t.

Customization

Aside from binding ace-window:

(global-set-key (kbd "M-o") 'ace-window)

the following customizations are available:

aw-keys

aw-keys - the list of initial characters used in window labels:

(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))

aw-keys are 0-9 by default, which is reasonable, but in the setup above, the keys are on the home row.

aw-scope

The default one is global, which means that ace-window will work across frames. If you set this to frame, ace-window will offer you only the windows of the current frame.

aw-background

By default, ace-window temporarily sets a gray background and removes color from available windows in order to make the window-switching characters more visible. This is the behavior inherited from ace-jump-mode.

This behavior might not be necessary, as you already know the locations where to look, i.e. the top-left corners of each window. So you can turn off the gray background with:

(setq aw-background nil)

aw-dispatch-always

When non-nil, ace-window will issue a read-char even for one window. This will make ace-window act differently from other-window for one or two windows. This is useful to change the action midway and execute an action other than the default jump action. By default, this is set to nil.

aw-dispatch-alist

This is the list of actions you can trigger from ace-window other than the jump default. By default it is:

(defvar aw-dispatch-alist
  '((?x aw-delete-window "Delete Window")
	(?m aw-swap-window "Swap Windows")
	(?M aw-move-window "Move Window")
	(?c aw-copy-window "Copy Window")
	(?j aw-switch-buffer-in-window "Select Buffer")
	(?n aw-flip-window)
	(?u aw-switch-buffer-other-window "Switch Buffer Other Window")
	(?c aw-split-window-fair "Split Fair Window")
	(?v aw-split-window-vert "Split Vert Window")
	(?b aw-split-window-horz "Split Horz Window")
	(?o delete-other-windows "Delete Other Windows")
	(?? aw-show-dispatch-help))
  "List of actions for `aw-dispatch-default'.")

When using ace-window, if the action character is followed by a string, then ace-window will be invoked again to select the target window for the action. Otherwise, the current window is selected.

aw-minibuffer-flag

When non-nil, also display ace-window-mode string in the minibuffer when ace-window is active. This is useful when there are many side-by-side windows and the ace-window-mode string is cutoff in the minor mode area of the modeline.

aw-ignored-buffers

List of buffers and major-modes to ignore when choosing a window from the window list. Active only when aw-ignore-on is non-nil. Windows displaying these buffers can still be chosen by typing their specific labels.

aw-ignore-on

When t, ace-window will ignore buffers and major-modes in aw-ignored-buffers. Use M-0 ace-window to toggle this value. :type 'boolean)

aw-ignore-current

When t, ace-window will ignore `selected-window'.

More Repositories

1

swiper

Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
Emacs Lisp
2,284
star
2

hydra

make Emacs bindings that stick around
Emacs Lisp
1,818
star
3

avy

Jump to things in Emacs tree-style
Emacs Lisp
1,704
star
4

lispy

Short and sweet LISP editing
Emacs Lisp
1,195
star
5

org-download

Drag and drop images to Emacs org-mode
Emacs Lisp
1,055
star
6

oremacs

My Emacs config
Emacs Lisp
296
star
7

auto-yasnippet

quickly create disposable yasnippets
Emacs Lisp
243
star
8

pamparam

Simple and fast flashcards for Emacs
Emacs Lisp
228
star
9

ace-link

Quickly follow links in Emacs
Emacs Lisp
210
star
10

lpy

Minimal Python IDE for GNU Emacs
Emacs Lisp
185
star
11

define-word

Display the definition of word at point in Emacs
Emacs Lisp
154
star
12

tiny

Quickly generate linear ranges in Emacs
Emacs Lisp
143
star
13

worf

vi-like bindings for org-mode
Emacs Lisp
132
star
14

function-args

C++ completion for GNU Emacs
Emacs Lisp
120
star
15

orca

ORg CApture
Emacs Lisp
104
star
16

swiper-helm

Helm version of swiper
Emacs Lisp
79
star
17

helm-make

Select a Makefile target with helm.
Emacs Lisp
62
star
18

plain-org-wiki

Simple jump-to-org-files in a directory package
Emacs Lisp
53
star
19

make-it-so

Transform files with Makefile recipes
Emacs Lisp
47
star
20

org-fu

My org-capture and org-protocol setup
Emacs Lisp
37
star
21

cook

Makefile -> Cookbook.py
Python
36
star
22

whicher

Audit and install the programs that your Emacs config depends on
Emacs Lisp
23
star
23

eclipse-theme

Eclipse theme for Emacs
Emacs Lisp
21
star
24

orly

Additional Org-mode link types and completion for them
Emacs Lisp
18
star
25

helm-j-cheatsheet

Quick J reference for Emacs
Emacs Lisp
17
star
26

zoutline

Emacs library for outlines
Emacs Lisp
16
star
27

gtk-pomodoro-indicator

A simple pomodoro indicator for Unity/GTK tray
Python
16
star
28

elf-mode

Show symbol list when opening a binary file in Emacs
Emacs Lisp
13
star
29

matlab-mode

My fork of matlab-mode
Emacs Lisp
13
star
30

short-lambda

Clojure-style anonymous function literal for Elisp
Emacs Lisp
12
star
31

centimacro

Assign multiple macros as global key bindings in Emacs
Emacs Lisp
12
star
32

xlx

XML <-> LISP converter
Common Lisp
11
star
33

eltex

Write LaTeX in Emacs Lisp
Emacs Lisp
10
star
34

headlong

reckless completion for Emacs
Emacs Lisp
10
star
35

semimap

.Xmodmap that uses semicolon as a modifier
8
star
36

dired-guess

Associate file extensions with programs that can open them for dired
Emacs Lisp
8
star
37

cc-chainsaw

A few tricks to make c++-mode go
Emacs Lisp
7
star
38

ukrainian-holidays

Ukrainian holidays for Emacs calendar
Emacs Lisp
7
star
39

org-mode

http://orgmode.org/org-mode.git
Emacs Lisp
6
star
40

profile-dotemacs

My mirror of http://www.randomsample.de/profile-dotemacs.el
Emacs Lisp
6
star
41

abel

abbrevs for Elisp
Emacs Lisp
5
star
42

touchpad

Toggle touchpad on/off
Python
5
star
43

cedet

My mirror of CEDET (http://cedet.sourceforge.net/).
Emacs Lisp
5
star
44

abo-abo.github.io

HTML
4
star
45

ido-occasional

Use ido where you choose
Emacs Lisp
4
star
46

netherlands-holidays

Netherlands holidays for Emacs calendar
Emacs Lisp
4
star
47

latex-wrap

Wrap selection with a LaTeX environment
Emacs Lisp
4
star
48

simple-benchmark

My notes comparing several PL on a simple benchmark
C++
4
star
49

ciao

Emacs Lisp
4
star
50

xkb-indicator

GTK indicator that allows to run setxkbmap via a keybinding
Python
2
star
51

malk

a simple multi-collection completion demo
Emacs Lisp
1
star
52

soap

Smart Operator a posteriori
Emacs Lisp
1
star