Linux – Vim visual selection method differs between Windows & Linux

gvimlinuxvimwindows

In Linux vim and gvim, I can make a visual selection by pressing V (e.g., v VISUAL or Shift+V VISUAL LINE), releasing it, and using movement keys (e.g., arrows) to highlight the desired text.

In Windows gvim, however, I must hold down Shift while I make my selection. Also, Ctrl+V (block) selection is supplanted by the Windows paste, and I can select text without v at all, like the common Windows method of Shift+arrow keys. I don't want any of this in my vim.

This is a minor annoyance at best, but there's probably a way to make Windows use the former (Linux) behavior of only pressing V once. I've scoured the docs to no avail. How can I dispense with all of this Windows stuff and get consistent behavior between my Windows and Linux environments?

Best Answer

When gvim starts, it sources a file called mswin.vim via the _vimrc file. In the mswin.vim file the keys are remapped. You can undo this two ways. One is edit the mswin.vim file and remove the mapping (not recommended). A second easier potentially less invasive way is to edit the _vimrc file.

 1. Start gvim as Administrator.  
 2. Click Edit->Startup Settings (This will load the _vimrc file)
 3. The beginning of the file will look something like this.

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

 4.  Delete the line that sources mswin.vim and sets mswin behavior and change set nocompatible to set compa`enter code here`tible.  The end result will look something like this.

set nocompatible
source $VIMRUNTIME/vimrc_example.vim

This should fix your problem.

If you want it to behave more like vi than vim, you can change nocompatible to compatible

Related Question