3

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?

  • Which version are you using? The version I have seems to work fine. – R Schultz Dec 1 '14 at 1:27
  • VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 27 2010 17:59:02) MS-Windows 32-bit GUI version with OLE support Included patches: 1-46 Compiled by Bram@KIBAALE Big version with GUI. Features included (+) or not (-): – type_outcast Dec 1 '14 at 1:30
2

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

  • Fantastic! My pinky fingers thank you. I'll upvote when I have the rep on this SE site. If it's not too much trouble, would you mind sharing how you figured this out? – type_outcast Dec 1 '14 at 2:56
  • 1
    Honestly. Semi educated-guessing/random clicking of the settings menu options. When the config file came up, I tried deleting the windows line and it worked. :) – R Schultz Dec 1 '14 at 2:58
  • 1
    Well, that explains it, then. My inelastic old brain just about never thinks to put click and text editor in the same thought-bubble. :-) – type_outcast Dec 1 '14 at 3:05
3

The easy method to resolve this issue is just to add:

set keymodel-=stopsel

to the C:\Program Files (x86)\vim\_vimrc file (for example after the behave mswin line).

Source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.