Skip to content

Conversation

superle3
Copy link

@superle3 superle3 commented Jul 20, 2025

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:

Screencast_20250720_171517.mp4

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

  1. given the following text and | is the cursor
Some important text|
  1. Select the text using the following
  • v0 (select the entire line)
  • <C-g> (switch to select mode)
  1. See the cursor change from block-cursor to insert cursor.
  2. Test a insert-only command, for example <C-x>, cuts the entire line/the selected text.
  3. Repeat 1-3 and test <C-g> again and test a visual-only command, for example d (cuts the entire line).

Implements replit#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant