Vim Tips Wiki
(Move categories to tip template)
 
(2 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
|id=239
 
|id=239
 
|previous=238
 
|previous=238
|next=240
+
|next=241
|created=May 2, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=Larry Clapp
 
|author=Larry Clapp
|version=5.7
+
|version=6.0
 
|rating=6/5
 
|rating=6/5
 
|category1=
 
|category1=
 
|category2=
 
|category2=
 
}}
 
}}
You can make Vim scroll the text using the shifted up/down arrows, sort of like your browser (except with shifted keys :), by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E.
+
You can make Vim scroll the text using the shifted up/down arrows by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E.
 
 
<pre>
 
<pre>
map &lt;s-Down&gt; &lt;C-E&gt;
+
map &lt;S-Down> <C-E>
map &lt;s-Up&gt; &lt;C-Y&gt;
+
map &lt;S-Up> <C-Y>
 
</pre>
 
</pre>
   
Line 25: Line 24:
 
If you normally use j and k for cursor movement, and rarely use the arrow keys, you can map the arrow keys directly, in which case I'd probably map the shifted arrow keys back to cursor movement:
 
If you normally use j and k for cursor movement, and rarely use the arrow keys, you can map the arrow keys directly, in which case I'd probably map the shifted arrow keys back to cursor movement:
 
<pre>
 
<pre>
map &lt;down&gt; &lt;c-e&gt;
+
map <Down> <c-e>
map &lt;up&gt; &lt;c-y&gt;
+
map <Up> <c-y>
map &lt;s-down&gt; j
+
map &lt;S-Down> j
map &lt;s-up&gt; k
+
map &lt;S-Up> k
 
</pre>
 
</pre>
   
Vim by default maps s-Down and s-Up to Ctrl-F and Ctrl-B, for both normal and visual mode. Keep this in mind if you change some of the above mappings to "nmap", because you'll probably also want to look in to "vmap".
+
Vim by default maps S-Down and S-Up to Ctrl-F and Ctrl-B, for both normal and visual mode. Keep this in mind if you change some of the above mappings to "nmap", because you'll probably also want to look in to "vmap".
   
 
==References==
 
==References==
Line 41: Line 40:
   
 
==Comments==
 
==Comments==
This would be great, but doesn't work with my combination of secure F SSH (windows) and TERM=xterm. The arrows cannot be mapped as &lt;up&gt;, etc, nor the &lt;home&gt; key. Any idea about why?
+
This would be great, but doesn't work with my combination of secure F SSH (windows) and TERM=xterm. The arrows cannot be mapped as <Up>, etc, nor the <home> key. Any idea about why?
  +
  +
:[[arrows]]
   
 
----
 
----

Latest revision as of 21:52, 2 August 2012

Tip 239 Printable Monobook Previous Next

created 2002 · complexity basic · author Larry Clapp · version 6.0


You can make Vim scroll the text using the shifted up/down arrows by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E.

map <S-Down> <C-E>
map <S-Up> <C-Y>

Shift-Down will then scroll down (like moving a scroll-bar down, or like moving a cursor at the bottom of a window down), and Shift-Up will then scroll up (like moving a scroll-bar up, etc).

If you'd rather think about the text moving down/up instead of the cursor moving up/down, you can of course swap the mappings.

If you normally use j and k for cursor movement, and rarely use the arrow keys, you can map the arrow keys directly, in which case I'd probably map the shifted arrow keys back to cursor movement:

map <Down> <c-e>
map <Up> <c-y>
map <S-Down> j
map <S-Up> k

Vim by default maps S-Down and S-Up to Ctrl-F and Ctrl-B, for both normal and visual mode. Keep this in mind if you change some of the above mappings to "nmap", because you'll probably also want to look in to "vmap".

References[]

Comments[]

This would be great, but doesn't work with my combination of secure F SSH (windows) and TERM=xterm. The arrows cannot be mapped as <Up>, etc, nor the <home> key. Any idea about why?

arrows