My Emacs configuration
git clone git://
Log | Files | Refs | LICENSE (6492B)

      1 # ace-window
      3 [![MELPA](](
      4 [![MELPA Stable](](
      6 **GNU Emacs package for selecting a window to switch to**
      8 ## What and why
     10 I'm sure you're aware of the `other-window` command.  While it's great
     11 for two windows, it quickly loses its value when there are more windows.
     12 You need to call it many times, and since it's not easily predictable,
     13 you have to check each time if you're in the window that you wanted.
     15 Another approach is to use `windmove-left`, `windmove-up`, etc.  These
     16 are fast and predictable.  Their disadvantage is that they need 4 key
     17 bindings.  The default ones are shift+arrows, which are hard to reach.
     19 This package aims to take the speed and predictability of `windmove`
     20 and pack it into a single key binding, similar to `other-window`.
     22 ## Setup
     24 Just assign `ace-window` to a short key binding, as switching windows
     25 is a common task.  I suggest <kbd>M-o</kbd>, as it's short and not
     26 bound to anything important in the default Emacs.
     28 ## Usage
     30 When there are two windows, `ace-window` will call `other-window`
     31 (unless `aw-dispatch-always` is set non-nil).  If there are more, each
     32 window will have the first character of its window label highlighted
     33 at the upper left of the window.  Pressing that character will either
     34 switch to that window or filter to the next character needed to select
     35 a specific window.  Note that, unlike `ace-jump-mode`, the position of
     36 point will not be changed, i.e. the same behavior as that of
     37 `other-window`.
     39 A special character defined by `aw-make-frame-char` (default = `z`)
     40 means create a new frame and use its window as the target.  The new
     41 frame's location is set relative to the prior selected frame's location
     42 and given by `aw-frame-offset`.  The new frame's size is given by
     43 `aw-frame-size`.  See their documentation strings for more information.
     45 The windows are ordered top-down, left-to-right. This means that if you
     46 remember your window layouts, you can switch windows without even
     47 looking at the leading char.  For instance, the top left window will
     48 always be `1` (or `a` if you use letters for window characters).
     50 `ace-window` works across multiple frames, as you can see from the
     51 [in-action gif](
     54 ## Swap and delete window
     56 - You can swap windows by calling `ace-window` with a prefix argument <kbd>C-u</kbd>.
     58 - You can delete the selected window by calling `ace-window` with a double prefix argument, i.e. <kbd>C-u C-u</kbd>.
     60 ## Change the action midway
     62 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:
     64 - <kbd>x</kbd> - delete window
     65 - <kbd>m</kbd> - swap windows
     66 - <kbd>M</kbd> - move window
     67 - <kbd>c</kbd> - copy window
     68 - <kbd>j</kbd> - select buffer
     69 - <kbd>n</kbd> - select the previous window
     70 - <kbd>u</kbd> - select buffer in the other window
     71 - <kbd>c</kbd> - split window fairly, either vertically or horizontally
     72 - <kbd>v</kbd> - split window vertically
     73 - <kbd>b</kbd> - split window horizontally
     74 - <kbd>o</kbd> - maximize current window
     75 - <kbd>?</kbd> - show these command bindings
     77 For proper operation, these keys *must not* be in `aw-keys`.  Additionally,
     78 if you want these keys to work with fewer than three windows, you need to
     79 have `aw-dispatch-always` set to `t`.
     81 ## Customization
     82 Aside from binding `ace-window`:
     84     (global-set-key (kbd "M-o") 'ace-window)
     86 the following customizations are available:
     88 ### `aw-keys`
     89 `aw-keys` - the list of initial characters used in window labels:
     91     (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
     93 `aw-keys` are 0-9 by default, which is reasonable, but in the setup
     94 above, the keys are on the home row.
     96 ### `aw-scope`
     97 The default one is `global`, which means that `ace-window` will work
     98 across frames.  If you set this to `frame`, `ace-window` will offer you
     99 only the windows of the current frame.
    101 ### `aw-background`
    103 By default, `ace-window` temporarily sets a gray background and
    104 removes color from available windows in order to make the
    105 window-switching characters more visible.  This is the behavior
    106 inherited from `ace-jump-mode`.
    108 This behavior might not be necessary, as you already know the locations
    109 where to look, i.e. the top-left corners of each window.
    110 So you can turn off the gray background with:
    112     (setq aw-background nil)
    114 ### `aw-dispatch-always`
    116 When non-nil, `ace-window` will issue a `read-char` even for one window.
    117 This will make `ace-window` act differently from `other-window` for one
    118 or two windows.  This is useful to change the action midway and execute
    119 an action other than the default *jump* action.
    120 By default, this is set to `nil`.
    122 ### `aw-dispatch-alist`
    124 This is the list of actions you can trigger from `ace-window` other than the
    125 *jump* default.  By default it is:
    127 	(defvar aw-dispatch-alist
    128 	  '((?x aw-delete-window "Delete Window")
    129 		(?m aw-swap-window "Swap Windows")
    130 		(?M aw-move-window "Move Window")
    131 		(?c aw-copy-window "Copy Window")
    132 		(?j aw-switch-buffer-in-window "Select Buffer")
    133 		(?n aw-flip-window)
    134 		(?u aw-switch-buffer-other-window "Switch Buffer Other Window")
    135 		(?c aw-split-window-fair "Split Fair Window")
    136 		(?v aw-split-window-vert "Split Vert Window")
    137 		(?b aw-split-window-horz "Split Horz Window")
    138 		(?o delete-other-windows "Delete Other Windows")
    139 		(?? aw-show-dispatch-help))
    140 	  "List of actions for `aw-dispatch-default'.")
    142 When using ace-window, if the action character is followed by a string,
    143 then `ace-window` will be invoked again to select the target window for
    144 the action.  Otherwise, the current window is selected.
    146 ### `aw-minibuffer-flag`
    148 When non-nil, also display `ace-window-mode` string in the minibuffer
    149 when `ace-window` is active.  This is useful when there are many
    150 side-by-side windows and the `ace-window-mode` string is cutoff in the
    151 minor mode area of the modeline.
    153 ### `aw-ignored-buffers`
    155 List of buffers and major-modes to ignore when choosing a window from
    156 the window list.  Active only when `aw-ignore-on` is non-nil.  Windows
    157 displaying these buffers can still be chosen by typing their specific
    158 labels.
    160 ### `aw-ignore-on`
    162 When t, `ace-window` will ignore buffers and major-modes in
    163 `aw-ignored-buffers`.  Use M-0 `ace-window` to toggle this value.
    164   :type 'boolean)
    166 ### `aw-ignore-current`
    168 When t, `ace-window` will ignore `selected-window'.