feat: implement select mode
Why
Implements #239
There are some usefull keybindings in insert mode while having something selected, for example surrounding the current selection with (), but selecting the right text is easier in visual mode than using a mouse or arrow keys. Vim also a select mode at https://vimhelp.org/visual.txt.html#Select, this only implements switching between visual and insert mode while keeping the selection and doesn't keep the selection mode (blockmode, linewise, normal).
Example:
https://github.com/user-attachments/assets/e3576505-6acf-4e5f-bb8a-e3d80fc8e65f
What changed
Adds an action binded to <C-g> that runs in insert mode and visual mode. If there is a selection, it switches between visual and insert mode while keeping the current selections.
Ideally it doesn't overwrite the <C-g> keybinding when there is no selection, but couldn't find a way to do that.
Test plan
- given the following text and | is the cursor
Some important text|
- Select the text using the following
-
v0(select the entire line) -
<C-g>(switch to select mode)
- See the cursor change from block-cursor to insert cursor.
- Test a insert-only command, for example
<C-x>, cuts the entire line/the selected text. - Repeat 1-3 and test
<C-g>again and test a visual-only command, for exampled(cuts the entire line).