Vim Tips Wiki
(Adjust previous/next navigation + minor manual clean)
(fix tip and incorporate comments)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{review}}
 
 
{{TipImported
 
{{TipImported
 
|id=864
 
|id=864
Line 6: Line 5:
 
|created=2005
 
|created=2005
 
|complexity=basic
 
|complexity=basic
|author=Bertram Scharpf
+
|author=
 
|version=6.0
 
|version=6.0
 
|rating=33/14
 
|rating=33/14
|category1=
+
|category1=Windows
 
|category2=
 
|category2=
 
}}
 
}}
On Windows, in visual mode the arrow keys do not work; they even end visual mode.
+
On Windows, new users may notice that the arrow keys end visual mode rather than extending the selection.
   
  +
If this happens, it is because of the <code>behave mswin</code> line in the default _vimrc installed on a Windows system.
Simply put this into your vimrc:
 
<pre>
 
vnoremap <Left> h
 
vnoremap <Right> l
 
vnoremap <Up> k
 
vnoremap <Down> j
 
</pre>
 
   
  +
The best solution is to simply remove this line from the global _vimrc, or to create your own _vimrc without it.
and the arrow keys behave like expected.
 
   
  +
However, if you like most of the effects of <code>behave mswin</code> (see {{help|behave}}) and only want to "fix" the visual selection behavior, simply put this into your vimrc after the <code>behave mswin</code>:
==Comments==
 
You can also add "behave xterm" to your vimrc, this will make the visual mode behave as expected. Or hold down the Shift key while selecting with the arrows. I guess this was added to make Vim behave more like a normal Windows text editior. Very confusing for experienced Vim users.
 
   
----
 
Also take a look at you system _vimrc file. There might be following lines:
 
<pre>
 
source $VIMRUNTIME/mswin.vim
 
behave mswin
 
</pre>
 
 
I deleted both of them an inserted some useful options that were set in vimrc_example.vim. After that Vim works under Windows like under Linux. :)
 
 
----
 
The same could be done by saying
 
 
<pre>
 
<pre>
 
set keymodel-=stopsel
 
set keymodel-=stopsel
 
</pre>
 
</pre>
   
  +
==References==
or by omitting
 
  +
* {{help|:behave}}
<pre>
 
  +
* {{help|'keymodel'}}
behave mswin
 
</pre>
 
   
 
==Comments==
----
 

Latest revision as of 15:46, 23 July 2012

Tip 864 Printable Monobook Previous Next

created 2005 · complexity basic · version 6.0


On Windows, new users may notice that the arrow keys end visual mode rather than extending the selection.

If this happens, it is because of the behave mswin line in the default _vimrc installed on a Windows system.

The best solution is to simply remove this line from the global _vimrc, or to create your own _vimrc without it.

However, if you like most of the effects of behave mswin (see :help behave) and only want to "fix" the visual selection behavior, simply put this into your vimrc after the behave mswin:

set keymodel-=stopsel

References[]

Comments[]