auto-scrollable pagination with vim using vertical split
I want to achieve the following: I want to split a vim session into two (or more) vertical windows (with the :vsplit command). Then, I want to have each window contents开发者_JAVA技巧 vertically offsetted so that the line after the last visible one of the first window becomes the first line of the second window. Then, when I use the arrows to scroll around, the vertical windows are scrollbound so that text flows from the second window into the first. How can I achieve this?
There are plugins for that: MultiPage
You can also use a oneliner described in this post by Chip Campbell:
:nmap <silent> <Leader>ef :vsplit<bar>wincmd l<bar>exe "norm! Ljz<c-v><cr>"<cr>:set scb<cr>:wincmd h<cr> :set scb<cr>
This will bind <Leader>ef
to open a vsplit and make the splits continuous.
First, split your window normally and position it according to your needs (last line in one, first line in the other).
Now, run :set scrollbind
in the first window. Jump to the second one and do the same, you can also use :set scb
for short.
That's it!
And be sure to read :h scroll-binding
.
精彩评论