Synchronized Scrolling in Split Editor
Problem
I have a feature request related to synchronized scrolling in the Split Editor. I checked for extensions and didn't see any. Was wondering if this is the pipeline or not.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Implement Synchronized Scrolling in Split Editor for VSCode
The Split Editor feature in Visual Studio Code does not currently support synchronized scrolling, which is a common requirement for developers who need to compare or reference code side by side. This limitation arises from the lack of built-in functionality to link the scroll positions of the two editors, leading to a disjointed user experience.
Awaiting Verification
Be the first to verify this fix
- 1
Check for Extension Availability
Before implementing a custom solution, verify if there are any existing extensions that can provide synchronized scrolling functionality. Use the Extensions view in VSCode to search for relevant extensions.
- 2
Create a Custom Extension
If no suitable extensions are found, create a custom VSCode extension that listens to the scroll events of one editor and applies the same scroll position to the other editor. Use the VSCode API to achieve this.
javascriptconst vscode = require('vscode'); function activate(context) { const editor1 = vscode.window.activeTextEditor; const editor2 = /* logic to get the second editor */; editor1.onDidChangeScrollPosition(() => { editor2.setScrollTop(editor1.document.lineAt(editor1.selection.active.line).range.start.line); }); } module.exports = { activate }; - 3
Test the Extension
Install the custom extension and open two files in the Split Editor. Scroll one editor and observe if the other editor scrolls in sync. Debug any issues that arise during this process.
- 4
Submit Feature Request to Microsoft
If the custom solution works well, consider submitting a feature request to Microsoft for native support of synchronized scrolling in future releases of VSCode. Include details of your implementation and its benefits.
Validation
To confirm the fix worked, open two files in the Split Editor and scroll one editor. The other editor should scroll in sync. Additionally, check for any errors in the developer console during the scrolling action.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep