Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I synchronously view and scroll vertically-split buffers in Vim?

Tags:

vim

I have two vertically-split buffers in Vim showing two separate files that I want both displayed and scrolled synchronously. With :set scrollbind at the top of both buffers, I can get the scrolling part down (so when I hit zt in one buffer, the current line jumps to the top in both buffers), but unfortunately, the display is not synchronized.

What this means is that if the lines in the files are of differing lengths, the two buffers won't be visually aligned. I'd like Vim to display extra line breaks in order to ensure that long wrapped lines do not interfere with the vertically-synchronized display of the two buffers.

Thanks!

like image 313
Ahmed Fasih Avatar asked Nov 08 '10 00:11

Ahmed Fasih


2 Answers

In addition to setting scrollbind in both buffers, you need to issue the command :syncbind . That should sync the scrolling. I don't know if it will do it perfectly if you're wrapping lines and the two files have lines of different lengths. But if you turn wrap off I think it should keep them at same line numbers.

like image 167
Herbert Sitz Avatar answered Sep 30 '22 12:09

Herbert Sitz


You can use

:set nowrap 

To stop the long lines from being wrapped, so that your buffers are synchronised. Not exactly what you asked, but close.

like image 35
janm Avatar answered Sep 30 '22 11:09

janm