Michaël Polla
Michaël Polla

Reputation: 4011

Synchronise vertical/horizontal scrolling in split view

Is there a way in VS Code to synchronise vertical or horizontal scrolling in splitted view ?

Like in Notepad++ for instance :

From buttons:

Notepad++ Vertical/Horizontal sync

From View menu:

Notepad++ Vertical/Horizontal sync

Upvotes: 105

Views: 79531

Answers (4)

Rich Werden
Rich Werden

Reputation: 1687

2024 EDIT: There is now an official editor-action named "View: Toggle Locked Scrolling Across Editors".

To engage it, open the Command Palette (⌘⇧P(Mac)/^⇧P(Win/Linux)) and type in the action name. Select it and hit enter.

See this official Youtube Short for a demo.

--

2021 Edit: While the below does still work, as per @Mr.D.Q's answer below, there does now exist a plugin Sync Scroll to accomplish this task.

--

From what I can find, the closest thing you can do is use the "Compare Files" feature.

In the File-Explorer sidebar:

  • Right-click on File A -> Select For Compare
  • Right-click on File B -> Compare With Selected

Upvotes: 136

Matt Ramos
Matt Ramos

Reputation: 34

I tried the Sync Scroll extension, but the scroll is not quite accurate. Instead, I found a better built-in approach. You can:

  1. Right click one of the files you wanna compare > Select for compare Select for compare

  2. Right click on the other file you wanna compare > Compare with selected Compare with selected

And walá! You'll have your files side by side and sync scroll works as a charm ;)

Upvotes: 1

starball
starball

Reputation: 51423

See issue ticket Synchronized Scrolling in Split Editor #33110. See the VS Code 1.88 release notes.

You can use the View: Toggle Locked Scrolling Across Editors command. Quoting one of the maintainers (Benjamin) in their comment:

[the command] will synchronize the scrolling across all text editors and notebooks. You can also set a keybinding for workbench.action.holdLockedScrolling which will synchronize the scrolling only when being pressed.

You can also bind a keyboard shortcut to the command ID workbench.action.holdLockedScrolling, which will synchronize scrolling only while that keyboard shortcut is being pressed.

Note that you can also use the "select for compare" feature to get a similar effect (see Visual Studio Code - is there a Compare feature like that plugin for Notepad ++?).

Upvotes: 20

dqisme
dqisme

Reputation: 562

If you want to more advanced synchronized scrolling feature, please check out this vscode extension Sync Scroll

Upvotes: 38

Related Questions