├── README.md └── select-view.kak /README.md: -------------------------------------------------------------------------------- 1 | # kakoune-select-view 2 | 3 | [kakoune](http://kakoune.org) command to select the visible part of a buffer. 4 | 5 | ## Install 6 | 7 | Add `select-view.kak` to your autoload dir: `~/.config/kak/autoload/`. 8 | 9 | Or via [plug.kak](https://github.com/andreyorst/plug.kak): 10 | 11 | ``` 12 | plug 'delapouite/kakoune-select-view' %{ 13 | # Suggested mappings 14 | map global normal ': select-view' -docstring 'select view' 15 | map global view s ': select-view' -docstring 'select view' 16 | } 17 | ``` 18 | 19 | ## Usage 20 | 21 | Sometimes you need to edit multiple occurrences of text that seat right under 22 | your nose but are distributed in such a way that they are impossible to quickly 23 | select using classic text objects. 24 | 25 | Also, you can't rely on the `%` primitive (select whole buffer), because it would 26 | expand your focus of action too far away and include portions of the buffer you 27 | don't want to change. 28 | 29 | As its name implies, the `select-view` command answers this problematic by only 30 | selecting the visible part of the buffer. 31 | 32 | It takes care of the `scrolloff` value which means it may scroll the buffer slightly. 33 | 34 | ## See also 35 | 36 | - [kakoune-phantom-selection](https://github.com/occivink/kakoune-phantom-selection) 37 | - [kakoune-vertical-selection](https://github.com/occivink/kakoune-vertical-selection) 38 | - [kakoune-text-objects](https://github.com/Delapouite/kakoune-text-objects) 39 | 40 | ## Licence 41 | 42 | MIT 43 | 44 | Thanks a lot to [alex](https://github.com/alexherbo2) for the original implementation on IRC 45 | -------------------------------------------------------------------------------- /select-view.kak: -------------------------------------------------------------------------------- 1 | # to restore the value afterwards 2 | declare-option -hidden str _scrolloff 3 | 4 | define-command select-view -docstring 'select visible part of buffer' %{ 5 | set-option window _scrolloff %opt{scrolloff} 6 | set-option window scrolloff 0,0 7 | 8 | execute-keys gtGbGl 9 | 10 | hook window -once NormalKey .* %{ 11 | set-option window scrolloff %opt{_scrolloff} 12 | } 13 | } 14 | 15 | # Suggested mapping 16 | 17 | #map global normal ': select-view' -docstring 'select view' 18 | #map global view s ': select-view' -docstring 'select view' 19 | --------------------------------------------------------------------------------