vimtricks.wiki Concise Vim tricks, one at a time.

How do I enable synchronized scrolling in every open window?

Answer

:windo setlocal scrollbind

Explanation

When reviewing related files side by side, manually keeping splits aligned wastes attention. scrollbind solves this by coupling window scroll positions, and :windo lets you enable it everywhere in one shot. This is especially useful for code review, refactors, and comparing generated output against source templates.

How it works

  • :windo executes an Ex command in each open window
  • setlocal applies the option per-window instead of globally
  • scrollbind links vertical scrolling behavior among bound windows

After running this command, moving through one window scrolls the others proportionally. Because the setting is local, you can selectively disable it in a specific pane later without touching the rest.

Example

Suppose you have three splits open:

left:  old implementation
mid:   new implementation
right: test file

Run:

:windo setlocal scrollbind

Now use <C-d> or j/k in one window and the other bound windows track the movement, keeping related sections visually aligned.

Tips

  • Pair with :setlocal cursorbind when you want cursor rows to stay synchronized too
  • Disable in all windows with :windo setlocal noscrollbind

Next

How do I append new keystrokes to an existing macro register without re-recording it?