Wikia

Vim Tips Wiki

Scroll using arrow keys like in a web browser

Talk0
1,610pages on
this wiki
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