Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/occivink/kakoune-phantom-selection

Work on multiple selections, one at a time
https://github.com/occivink/kakoune-phantom-selection

kakoune plugin selection

Last synced: 28 days ago
JSON representation

Work on multiple selections, one at a time

Awesome Lists containing this project

README

        

# kakoune-phantom-selection

[kakoune](http://kakoune.org) plugin to work on multiple selection one by one. Just a thin wrapper around marks to solve a common use-case.

[![demo](https://asciinema.org/a/152289.png)](https://asciinema.org/a/152289)

## Setup

Add `phantom-selection.kak` to your autoload dir: `~/.config/kak/autoload/`, or source it manually.

## Usage

With multiple selections, call `phantom-selection-iterate-next` or `phantom-selection-iterate-prev`. The main selection will remain, and the others will be put in a "dormant" state (but still visible). You can then cycle back and forwards by calling these commands again.
You can build the phantom selections using normal kakoune primitives or by calling `phantom-selection-add-selection` to add the current ones. This is useful when the selections you want do not share obvious similarities.
Finally, calling `phantom-selection-select-all` will restore all the dormant selection, and `phantom-selection-clear` will remove them instead.

I personally use the following mappings, since I don't find `select onto` too useful. You can use `user` mode instead of `normal`.
```
map global normal f ": phantom-selection-add-selection"
map global normal F ": phantom-selection-select-all; phantom-selection-clear"
map global normal ": phantom-selection-iterate-next"
map global normal ": phantom-selection-iterate-prev"

# this would be nice, but currrently doesn't work
# see https://github.com/mawww/kakoune/issues/1916
#map global insert ": phantom-selection-iterate-next"
#map global insert ": phantom-selection-iterate-prev"
# so instead, have an approximate version that uses 'i'
map global insert ": phantom-selection-iterate-nexti"
map global insert ": phantom-selection-iterate-previ"
```

## Customization

The script can be modified by changing the value of the face `PhantomSelection` (default `black,green+F`), you probably want to keep the face 'final' by setting the `+F` attribute.

## Tests

The `test.kak_` file contains tests for the plugin. To execute these tests, simply run `kak -n -e 'source test.kak_ ; quit'`: if the kakoune instance stays open, the tests have somehow failed and the current state can be inspected.

## License

Unlicense