1

Emacs has a neat built-in feature called Follow mode, which splits the screen an then lays out the current buffer linearly across these splits (and follows along when scrolling). As such, one may follow code, etc, over a higher span of text.

Does anyone know if this is supported natively in ViM, or else exists as a plugin?

1
  • I definitely saw a plugin like this on this site… but I know I won't be able to find it… grr
    – D. Ben Knoble
    Commented Dec 7, 2022 at 15:12

2 Answers 2

3

One way to do that would be with the following commands:

  • ctrl+w v To create a new split with the same buffer
  • ctrl-w w To go to the new split (or any other command you see fit like ctrl+w l)
  • L To move the cursor to the last line of the new split
  • zt To move this line to the top of the split
  • :windo set scrollbind To set :h 'scrollbind' on both of your window, allowing you to sync the scroll between them.

This is a general idea: You could put that in a function and have a mapping calling the function and you might also want to handle some edge cases.For example, here if you have several split already open things will get messy so you might want to use :h winnr() before and after ctrl+w v to keep the id of the windows and instead of windo use two commands to enable scrollbind only on the ids you saved.

2
  • That's promising! As you said, the third opened split after following that list got lost immediately. What do you mean by "keep the id of the windows"? scrollbinddoes not seem to take any arguments. Commented Dec 7, 2022 at 19:45
  • scrollbind doesn't take arguments but if you store the result of :h win_getid() before you create the split and after you create the split in two variables you can then use :h win_gotoid() to set scrollbind on both windows.
    – statox
    Commented Dec 9, 2022 at 12:57
1

There is the multipager plugin from the prolific DrChip that spreads a file across multiple windows. I'm not sure if that is what you are asking for. This plugin lays it out like pages in a book:

Here is some |it continues |(and the next 
text in one  |in the next  |one too).
buffer and   |window over  |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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