Git Product home page Git Product logo

ace-window's Introduction

ace-window

GNU Emacs package for selecting a window to switch to

What and why

I'm sure you're aware of 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-p, as it's short and not bound in the default Emacs.

Usage

When there are two windows, ace-window will call other-window. If there are more, each window will have its first character highlighted. Pressing that character will switch to that window. Note that, unlike ace-jump-mode, the point position will not be changed: it's the same behavior as that of other-window.

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.

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.

  • You may replace the target window with the current one while closing current one by calling ace-window with a negative prefix argument, i.e. C--

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 window
  • M - move window
  • r - replace window
  • v - split window vertically
  • b - split window horizontally
  • n - select the previous window
  • i - maximize window (select which window)
  • o - maximize current window

In order for it to work, these keys must not be in aw-keys and you have to have aw-dispatch-always set to t.

Customization

Aside from binding ace-window:

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

maybe you'd like the following customizations:

aw-keys

aw-keys - the sequence of leading characters for each window:

(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 the windows only on 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 other action other than the jump default. By default is set to nil

aw-dispatch-alist

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

(defvar aw-dispatch-alist
'((?x aw-delete-window " Ace - Delete Window")
    (?m aw-swap-window " Ace - Swap Window")
    (?n aw-flip-window)
    (?v aw-split-window-vert " Ace - Split Vert Window")
    (?b aw-split-window-horz " Ace - Split Horz Window")
    (?i delete-other-windows " Ace - Maximize Window")
    (?o delete-other-windows))
"List of actions for `aw-dispatch-default'.")

If the pair key-action is followed by a string, then ace-window will be invoked again to be able to select on which window you want to select the action. Otherwise the current window is selected.

ace-window's People

Contributors

abo-abo avatar kyleam avatar joedicastro avatar damiencassou avatar kaushalmodi avatar demon386 avatar skotchandsoda avatar deftsp avatar tsdh avatar itsjeyd avatar larkery avatar

Watchers

Sooheon Kim avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.