Synchronise vertical/horizontal scrolling in split view
Asked Answered
A

3

89

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

Atropos answered 26/7, 2017 at 11:44 Comment(1)
Looks like it is a feature request, see github.com/Microsoft/vscode/issues/18137 but not with a lot of momentum other than for markdown previews.Goatsbeard
B
110

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
Behoove answered 7/8, 2018 at 2:59 Comment(5)
That's a nice workaround ! I'll mark your answer as accepted, until maybe one day VSCode offers a true way to synchronise vertical and horizontal scrolling.Incandescence
This only works for the scenario when you want to compare very similar files. A lot of other times this feature does not work well.Lesbian
I just want to emphasize the SIDEBAR EXPLORER and not the top file navigation bar.Fillagree
The first answer's the best. With Sync Scroll, if A file contains more lines than B file, then there is a gap between them. The native 'Select for Compare' + 'Compare with Selected' is more accurate :)Vasilikivasilis
Sync Scroll works! Two issues though: 1. Doesnt work for horizontal scrolling. 2. If you manually horizontal-scroll both files and then scroll vertically, one of the file resets the horizontal scroll back to start.Ascus
J
37

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

Jaco answered 3/6, 2020 at 21:44 Comment(0)
S
11

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 ++?).

Shorthanded answered 4/3 at 6:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.