Introduction
Choosy is a Vim plugin for quickly preforming actions on windows via a interactive selection mechanism. Vim typically operates with a verb-object syntax, and Choosy does the same. For example, you might type <leader>cwc
(verb: choose window to close) then pick the window you want to close (the object, or target).
Choosy was inspired by vim-choosewin but is more configurable, allowing the user to specify the actions to take on the target window.
Features
When run, Choosy displays a popup at the center of each window. Each popup shows a letter or the window number (configurable). To choose the window, type the given letter/number. Choosy closes all of the popups it opened and executes an action.
What actions? Pretty much anything you like. Choosy comes with a number of example actions (see below) such as jumping to a window, splitting a window, closing a window, or swapping buffers between windows. But part of the power of Choosy is that you can easily set up your own actions. Here's an example call to Choosy that splits a selected window into 3 parts:
nnoremap <leader>3 :Choosy call win_execute({win.winid}, "sp {bar} sp")<cr>
The {win.winid}
gets replaced with the window ID of the window you chose, and the {bar}
gets replacded with the |
command separator. See the docs for full information, or plugin/choosy.vim for more examples.
Default mappings
Choosy comes with a set of default mappings starting with <leader>cw
("choose window"):
<leader>cwh
: split the target window horizontally<leader>cwv
: split the target window vertically<leader>cwc
: close the target window<leader>cws
: swap the buffers in this window and the target one, with the cursor following this buffer<leader>cwS
: swap the buffers in this window and the target one, with the cursor Staying in the current window<leader>cwD
: show this buffer in the target window ("Duplicate")
If NERDTree is installed, an additional set of mappings are available to open files from NERDTree in a target window. These start with <leader>co
("choose open"):
<leader>cow
: open in the target window<leader>coh
: open in a horizontal split of the target window<leader>cov
: open in a vertical split of the target window
Installing
Choosy requires a recent Vim which supports popup windows and optional function arguments.
Choosy has not been tested on versions < 8.1 (patch 2110), nor on nvim.
To install, use your package manager of choice. For example, with
vim-plug add to your vimrc
:
Plug 'anjiro/vim-choosy'
Screenshots
Note that these screenshots have syntax higlighting turned off to make the Choosy popups more visible.
Basic configuration:
With g:choosy_color_popups
and g:choosy_key_winnr
set: