vimtricks.wiki Concise Vim tricks, one at a time.

How do I switch between visual mode and select mode in Vim?

Answer

v{motion}<C-g>

Explanation

Vim has a lesser-known select mode that behaves like selection in typical GUI editors: any typed character replaces the selection. You can toggle between visual mode and select mode using <C-g> while a selection is active. This is useful when you want to quickly replace a block of text by typing over it.

How it works

  • v{motion} — start visual mode and select text with any motion
  • <C-g> — toggle from visual mode to select mode (or back)
  • In select mode, typing any printable character replaces the entire selection with that character and puts you in insert mode
  • Press <C-g> again to toggle back to visual mode

Select mode is essentially visual mode with "type-to-replace" behavior, making it feel more like a traditional text editor.

Example

Starting with:

The quick brown fox
  1. Press vee to visually select quick brown
  2. Press <C-g> to enter select mode
  3. Type slow red — the selection is replaced and you are in insert mode

Result:

The slow red fox

Tips

  • Enter select mode directly with gh, gH, or g<C-h> (character, line, and block select modes)
  • <C-o> in select mode executes one visual-mode command and returns to select mode
  • Useful in snippet/template systems where placeholders should be replaced by typing

Next

How do I ignore whitespace changes when using Vim's diff mode?