Vim Tips Wiki
No edit summary
 
(fix tip and incorporate comments)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
{{TipImported
{{review}}
 
{{Tip
 
 
|id=864
 
|id=864
  +
|previous=863
|title=Windows: make arrow keys work in visual mode
 
  +
|next=868
|created=February 1, 2005 8:23
+
|created=2005
 
|complexity=basic
 
|complexity=basic
  +
|author=
|author=Bertram Scharpf <vim--AT--bertram-scharpf.de>
 
 
|version=6.0
 
|version=6.0
 
|rating=33/14
 
|rating=33/14
  +
|category1=Windows
|text=
 
  +
|category2=
On windows, in visual mode the arrow keys do not work, they even end visual mode.
 
 
 
 
Simply put this into your _vimrc:
 
 
 
 
vnoremap &lt;left&gt; h
 
 
vnoremap &lt;right&gt; l
 
 
vnoremap &lt;up&gt; k
 
 
vnoremap &lt;down&gt; j
 
 
 
 
and - voil� - they arrow keys behave like expected.
 
 
 
 
(Googling for "vim windows visual arrow" finds everything, so I'm glad you found this tip.)
 
 
 
 
}}
 
}}
  +
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.
== 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 vim experienced users :-)
 
 
'''Anonymous'''
 
, February 1, 2005 14:49
 
----
 
Also take a look at you system _vimrc file. There might be following lines:
 
source vimrc_example.vim " or maybe some other file; I don't remember exactly its name
 
behave mswin
 
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. :)
 
 
Ivan Tishchenko
 
, February 2, 2005 4:18
 
----
 
Sorry! The same could be done by saying
 
 
set keymodel-=stopsel
 
   
  +
The best solution is to simply remove this line from the global _vimrc, or to create your own _vimrc without it.
or by omitting
 
   
  +
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>:
behave mswin
 
   
  +
<pre>
at all.
 
 
set keymodel-=stopsel
  +
</pre>
   
  +
==References==
Why doesn't anybody enlighten me about that?
 
  +
* {{help|:behave}}
  +
* {{help|'keymodel'}}
   
 
==Comments==
Bertram Scharpf
 
, February 15, 2005 4:46
 
----
 
<!-- parsed by vimtips.py in 0.500441 seconds-->
 

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[]