I can vertically split windows for the current file by :vs. Is there any way that I can sync cursor movement in the two windows? E.g. if the cursor in the left window moves up two lines, I want the cursor in the right window moves up two lines as well, regardless which lines the cursors were before the movement.

I've tried cursorbind from this post, but it just change the cursor to the same position in the two windows. I also type :set scrollbind in the two windows, but but it only works when the cursor is on the top/bottom of the screen and it's a bit inconvenient. I wonder if there is a better solution.

update 1

The original problem is that I have a Python program like this and the output is redirected to a file:

for dataframeVariable in listDataframeVariable: # list length is 10

I'd like to visually compare the content of the two prints. I know one workarond is to write a MACRO to move every second print to the end of the file, and move the appending content to another file, and use vimdiff to compare.

Do we have a better solution?

  • 2
    At first it seems not possible in Vim standard. Maybe if you give more information about why you want to have that someone can propose a solution to your original problem. Commented Jan 17 at 9:14
  • Agreeing with Vivian. A minimal example might help people understand what you're looking for.
    – Friedrich
    Commented Jan 17 at 9:32
  • 1
    There is only one cursor, the one in the current window, so binding two cursors in two windows is an ontological impossibility. Moreover, scrollbind only requires the cursor to be at the top/bottom of the screen if you incorrectly use jk or the arrows for scrolling. Actual scrolling commands like <C-e> or <C-y> allow the bound windows to scroll in sync, wherever the cursor is in either window.
    – romainl
    Commented Jan 17 at 9:32
  • A possible workaround to make "incorrect scrolling" work may be to force the cursor to the center line through :set scrolloff=999 as suggested in :help 'scrolloff'.
    – Friedrich
    Commented Jan 17 at 9:49
  • I understand your original question, and I understand the actual problem you're trying to solve, but I don't understand how answering the question would solve your problem!
    – Rich
    Commented Jan 19 at 9:36

1 Answer 1


You could be interested by the following spotdiff plugin.

It allows you to select a range in one window and a range in another window and ask Vim to compare both.

Select the first spot and run :Diffthis enter image description here

Select the second spot and run :Diffthis enter image description here

A temporary buffer is created I have moved aside using Ctrl wL enter image description here

When your are done run :Diffoff enter image description here

enter image description here


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.