Closed NNBnh closed 1 year ago
I'm afraid this would not be possible as there's actually no 'select' mode. The select mode is more of a 'submode' of normal mode if you will. You see, there's nothing preventing you from having a selection (a cursor with a position different than it's anchor) outside the selection submode.
It could be possible to create custom commands that do what you want through a code plugin and then map them to keys in normal mode.
However, it would be some really verbose solution.
On another thought, we could make an if
command that conditionally executes other commands
and an some @has-selection()
expansion that would evaluate to true when on selection submode.
Then you'd be able to do something like this:
command on-backspace-normal-mode @{
if @has-selection() @{
enqueue-keys cVcvhd # delete one character to the left
} else @{
enqueue-keys <esc> # cancel selection
}
}
map normal <backspace> :<space>on-backspace-normal-mode<enter>
Not really ideal, but could work.
This is actually possible in the upcoming v0.29.0 (currently on branch parse-multi-cursors
).
In that version, you can do:
command on-backspace-normal-mode @{
if @cursor-anchor() != @cursor-position() @{
enqueue-keys cVcvhd # delete one character to the left
}
if @cursor-anchor() == @cursor-position() @{
enqueue-keys <esc> # cancel selection
}
}
map normal <backspace> :<space>on-backspace-normal-mode<enter>
Will close this since it's possible to implement with custom commands.
We currently have:
Unfortunate there is no support for mapping on selection mode, but if
map select
is support this will open up many possibility for user to make the editor way more convenient for examples: