Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll the other window in VIM Split

Tags:

vim

scroll

How do I scroll the other window in :vsplit in VIM? I've looked everywhere, but all websites are talking about how to sync both windows to scroll together. I want to look at one file, edit it, while scrolling the other.

like image 573
darksky Avatar asked Feb 28 '12 22:02

darksky


1 Answers

I'm fairly (ok, quite) certain there's nothing built in to do this, not least of all because it only makes sense when there are exactly two windows. For that specific case, however, you can use a mapping. Put these in your ~/.vimrc:

nmap <a-j> <c-w>w<c-e><c-w>w
nmap <a-k> <c-w>w<c-y><c-w>w

This will make Alt+J scroll down and Alt+K up, you can change those as you like. If you want it to work with more windows, you'll have to write a script.

like image 67
Kevin Avatar answered Oct 07 '22 23:10

Kevin