Set up
- Left (L) and right (R) are two vertically split windows displaying the same file.
- No other windows exist in the tab.
- The uppermost displayed line in L is x (
Lx
) and the uppermost line in R is y (Ry
). - The focused window is denoted by an asterisk (
*L
or*R
).
Question
I am looking for a normal mode map to do this:
- If L has focus: Change
*Lx Ry
into*Lx Rx
. - If R has focus: Change
Lx *Ry
intoLy *Ry
.
I.e., I want the offset between the windows to be zero.
Attempts
syncbind
almost solves the problem, but since it requires both windows
to have scrollbind
set, and I rarely have it set, things get more complicated.
windo
would apparently solve it:
noremap <F11> :windo set scb<bar>syncbind<CR>:windo set noscb<CR>
But although it works properly for case 2, it fails for case 1 because it shifts focus to the right window.
windo
. You could save the currentwinnr()
and useexecute winnr 'wincmd w'
or similar:h windo
: "The last window (or where an error occurred) becomes the current window". I will give it a try. I only wish we had asyncbind!
to remove the offset of all windows regardless ofscrollbind
...