How do I enter a mode where I select text and then typing immediately replaces the selection, like in most graphical editors?
Answer
gh
Explanation
Vim's Select mode behaves like the familiar selection model in most GUI editors: after selecting text, any printable character you type replaces the selection and drops you into Insert mode. This is distinct from Visual mode, where typing commands (like d, y, c) operate on the selection rather than replace it.
How it works
gh— start character-wise Select mode (likevbut Select mode instead of Visual)gH— start line-wise Select mode (likeV)g<C-h>— start block-wise Select mode (like<C-v>)- Once in Select mode, extend the selection with any motion or text object
- Type a printable character to delete the selection and enter Insert mode with that character already typed
- Press
<C-o>to execute one Normal mode command and return to Select mode - Press
<Esc>to return to Normal mode without replacing
Example
With the cursor on the word old in the old dog:
the old dog (cursor on 'o' of 'old')
Press ghiw (Select mode + inner word), then type new:
the new dog
The word was selected and replaced by typing, just like in a typical editor.
Tips
- Select mode is triggered automatically by some plugins (e.g., snippet placeholders) — knowing how to navigate it makes snippet workflows smoother
:set selectmode+=mousemakes mouse-drag selections use Select mode instead of Visual mode:set selectmode+=keyenables Select mode for shifted motion keys (like<S-Right>)- In Select mode,
<C-g>toggles back to Visual mode with the same selection intact