raw Software
RAW Software Development Tools Text Editors

Disable Vim Visual Mode on Mouse Selection

Robert Eisele

When Vim handles mouse events inside a terminal, dragging selects text in Vim and enters Visual mode instead of using the terminal's native text selection. Disable Vim's mouse integration to let the terminal receive those drag events again.

Disable Mouse Handling for the Current Session

Run this command inside Vim:

:set mouse=

The empty value disables mouse handling in every Vim mode. Mouse dragging then belongs to the terminal, so text can be selected and copied normally.

Make the Change Permanent

Add the same option to ~/.vimrc:

set mouse=

For Neovim configured with Vimscript, add it to ~/.config/nvim/init.vim. In a Lua configuration, use:

vim.opt.mouse = ""

Inspect and Restore the Setting

To inspect the current value and where it was last set, run:

:verbose set mouse?

A common distribution default is mouse=a, which enables mouse support in all available modes. Restore that behavior for the current session with:

:set mouse=a

Alternatively, restore Vim's compiled default value with:

:set mouse&

Why mouse-=a Is Less Reliable

The older command :set mouse-=a removes only the literal a flag. It works when the option is exactly mouse=a, but it does not disable flags listed separately, such as mouse=nvi. Assigning an empty value is explicit and works regardless of the previous combination.

If mouse support should remain enabled in Vim, many terminal emulators also allow native selection while holding Shift. That behavior belongs to the terminal emulator and is not consistent across all terminals.