How to bind scrolling horizontal split windows?

89 views
Skip to first unread message

Igor

unread,
Feb 21, 2022, 8:11:13 AM2/21/22
to vim_use
Hi,
I am using Vim 7.4 on Linux.

Open text file:
:e some_file

Split the same buffer to another window:
:sp

Turn off long line wrap:
:set nowrap

Bind scrolling of both windows:
:set scrollbind

Now move up and down a buffer and both windows scroll together.

Now to the actual problem. I have text of multiple columns with header. When I move down a buffer I no longer see head of columns, so I vertically slit window. Top window is at first line position to see column headers, bottom window I use to see data in e.g. 1000 row. I can easily in e.g. column 5 the data in line 1000 and header from line 1. But when in e.g. bottom window I scroll to the right, I would like both windows to scroll to the right like they are bound together, so I can see e.g. 100 columns body and header, but instead only current buffer in current window is scrolled.

Now instead of ":sp" in second command turn on vertical split screen ":vsp" How to turn on vertical scrollbind?
Regards

Gary Johnson

unread,
Feb 21, 2022, 9:01:46 AM2/21/22
to vim_use
On 2022-02-21, Igor wrote:
> Hi,
> I am using Vim 7.4 on Linux.

> Now to the actual problem. I have text of multiple columns with header. When I
> move down a buffer I no longer see head of columns, so I vertically slit
> window. Top window is at first line position to see column headers, bottom
> window I use to see data in e.g. 1000 row. I can easily in e.g. column 5 the
> data in line 1000 and header from line 1. But when in e.g. bottom window I
> scroll to the right, I would like both windows to scroll to the right like they
> are bound together, so I can see e.g. 100 columns body and header, but instead
> only current buffer in current window is scrolled.

The 'scrollopt' option lets you choose to bind vertical scrolling
(the default), horizontal scrolling, or both.

:e some_file
:set nowrap
:set scrollopt-=ver
:set scrollopt+=hor
:set scrollbind
:split

See

:help 'scrollopt'

> Now instead of ":sp" in second command turn on vertical split screen ":vsp" How
> to turn on vertical scrollbind?

I'm not sure I understand you. Vertical scrollbinding is the
default. Do you mean that you want something like this, where the
buffer is vertically split but each half has the column headers
above it, with the vertically-split windows vertically scrollbound
while the horizontally-split windows are horizontally scrollbound?

+---------+---------+
| headers | headers |
+---------+---------+
| | |
| body | body |
| | |
+---------+---------+

Unfortunately for this case, 'scrollopt' is a global option. You
can have all scrollbound windows scroll together horizontally or
vertically (or both), but you can't have some windows bound
horizontally while others are bound vertically.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages