declare-user-mode anchor
map global anchor a '<esc><a-;>;' -docstring 'reduce to anchor'
map global anchor c '<esc>;' -docstring 'reduce to cursor'
map global anchor f '<esc><a-;>' -docstring 'flip cursor and anchor'
map global anchor h '<esc><a-:><a-;>' -docstring 'ensure anchor after cursor'
map global anchor l '<esc><a-:>' -docstring 'ensure cursor after anchor'
map global anchor s '<esc><a-S>' -docstring 'select cursor and anchor'
map global normal ';' ': enter-user-mode anchor<ret>'
Nothing fancy but I find these shortcuts more complete and easier to memorize than the native ;, <a-;> and <a-:> trio.
I feel like sometimes it’s better to sacrifice one direct access key (; in this case) to open up a whole new sub mode of related commands.
… I had to quote the ; to avoid a syntax error at startup; Kakoune sees the ; as the end of the statement and complains about “insufficient arguments to command”.
I like the command you added to ensure selections are in backward direction.
However, I’m not convinced with the command to reduce selections to their anchor. Although I understand the convenience due to a non direct access for flipping, it feels like it misses one step, or a visual effect to sound natural.
I’ve found that with locking, there is no need to remember mode’s keys. Also extended it with kind of undo key, which restores original selection:
declare-user-mode anchor
map global anchor a '<a-;>;' -docstring 'reduce to anchor'
map global anchor c ';' -docstring 'reduce to cursor'
map global anchor f '<a-;>' -docstring 'flip cursor and anchor'
map global anchor h '<a-:><a-;>' -docstring 'ensure anchor after cursor'
map global anchor l '<a-:>' -docstring 'ensure cursor after anchor'
map global anchor s '<a-S>' -docstring 'select cursor and anchor'
map global anchor u 'z' -docstring 'restore selection'
map global normal ':' 'Z: enter-user-mode -lock anchor<ret>'