Feature request: option for `w` and `b` to move by/select whole words instead of to the start of a new word.
See original GitHub issueIssue Description
I used this plugin on Kakoune and have found it more convenient than Kakoune’s normal behaviour. AFAIU, the plugin makes it such that the word navigation keys w
and b
move/select whole words (excluding trailing whitespaces) instead of moving to/selecting to the end/start of the current word (which is instead done with W
and B
, and which also excludes trailing whitespaces). It would be nice if there was an option to enable the same behaviour for Dance.
I’ve included some example expected behaviours if this hypothetical option was enabled in Dance. For each example, the first row is the buffer’s state before input, second is the input (in normal mode), and the third is the buffer’s state after the input. |
is where the cursor is, [
and ]
indicates the start and end of selection. These assume caret selection is enabled.
word_a wor|d_b word_c
w
:
word_a [word_b]| word_c
word_a wor|d_b word_c
b
:
word_a |[word_b] word_c
wor|d_a word_b word_c
ww
:
word_a [word_b]| word_c
word_a word_b wor|d_c
bb
:
word_a |[word_b] word_c
word_a wor|d_b word_c
W
:
word_a wor[d_b]| word_c
word_a wor|d_b word_c
B
:
word_a |[wor]d_b word_c
wor|d_a word_b word_c
WW
:
wor[d_a word_b]| word_c
word_a word_b wor|d_c
BB
:
word_a |[word_b wor]d_c
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
I think I know what the issue is. First of all, to search backwards you should use
dance.search.backwards
with input\\w
(the input is a RegExp). Second of all, you can usedance.selections.{backward,forward}
to change the direction of the selections.Unfortunately I did some debugging and
no selections remaining
still happens in that case and worse yet, it somehow prevents the code from working correctly. I have an idea of where the issue comes from (some off by one errors when handling selections that does not seem to happen incharacter
mode) but I haven’t been able to fix it yet.Looking at it, it looks like it’s implemented by invoking existing Kakoune commands. I spent some time trying to replicate this and some changes were needed, but in
0.4.2
you can have this kind of keybinding:And similar keybindings with
WbB
(replacing the arguments ofobjects.performSelection
as needed). Unfortunately there is a bug in the above code that will lead to “no selections remaining” being printed in some cases, but I haven’t found out why yet (and you can probably work around this).In the future I’d like to make keybindings scriptable and to improve the scripting API, but for now this will have to do.