Wikia

Vim Tips Wiki

Changes: Scroll using arrow keys like in a web browser

Edit

Back to page

(adjust previous/next navigation + minor manual clean)
(Comments)
 
Line 41: Line 41:
 
==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 <Up>, etc, nor the <home> 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, August 2, 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".

ReferencesEdit

CommentsEdit

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

Around Wikia's network

Random Wiki