2

Suppose I have a long python file which is limited to 79 character or so in width. One very helpful feature would be if I could view the whole file separated into multiple vertical splits which "extends" each other. This way, a wide monitor or laptop screen could be utilized more efficiently. Does such a vim plugin exist? Opening the same file in multiple splits would not cut it since both moving, editing and saving should impact all the splits.

E.g. If first split shows line 1-50, next would show line 51-100 and so on. And if I would move down in my first split, now showing line 25-75, the split nr.2 would then in turn visualize line 76-125 or something.

2

The 'scrollbind' option allows you to do what you want.

Here's how you can set up 2 windows to scroll together:

  1. :vsplit to have two windows showing the same buffer. They start with the same viewport.
  2. :set scrollbind in the current window
  3. Switch to the other window. Adjust it to display the next "page" of text.
    1. L to move the cursor to the bottom of the second window
    2. zt to scroll the buffer so the cursor's line is at the top of the window. Now the last line in the first window is the first line in the second window.
    3. Ctrl+e to scroll the buffer up one line, so each window is now displaying their own distinct, but continuous views of the buffer.
  4. :set scrollbind so the second window scrolls along with the first window

You can repeat these steps for any other windows you want to be part of the same bound group of windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.