Two windows in a split windows view of Vim can be bound to each other for scrolling by setting :set scrollbind
for both of them. After this is done, if I scroll down the cursor in one windows, the other windows scrolls down along with it.
But, the cursors in the two windows are not bound to each other. I have used :set cursorline
to highlight the current line on which the cursor is present. How do I make the highlighted cursorline to scroll simultaneously in the other window too?
I don't use this myself, and I may be missing the point, but
:set cursorbind
seems to do exactly what you want.
I just encountered the same situation (with only two windows to compare), and what I did was:
:set cursorbind
:set scrollbind
:set cursorline
and then
:map <Down> j<C-w><C-w><C-w><C-w>
:map <Up> k<C-w><C-w><C-w><C-w>
This causes every press on the up or down arrows to switch back and forth between the windows once, which updates the cursor position on the other window (You can :redraw!<CR>
instead of the ugly window switching but that looks bad when moving too fast). Of course, there are many ways to move between lines without the arrows, so this is far from perfect.
However, since this is not a main mode of work for me, useful primarily for comparing files on which diff
is too complicated to look at for whatever reason, I find this setting to be practically good enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With