Reputation: 1554
IntelliJ IDEs have a button called "Collapse Unchanged Fragments", which hides most code lines that have stayed the same and fit the relevant information in way less space. Is there something similar in VS Code? If so, how do you enable it?
Upvotes: 10
Views: 3062
Reputation: 181060
Just to update the accepted answer. In Stable v1.82 are these settings and keybindings:
Diff Editor > Hide Unchanged Regions: Enabled
Diff Editor > Hide Unchanged Regions: Context Line Count
Diff Editor > Hide Unchanged Regions: Minimum Line Count
Diff Editor > Hide Unchanged Regions: Reveal Line Count
Diff Editor > Experimental: Use Version2 // now defaults to enabled/true
and these keyboard shortcuts:
Diff Editor: Collapse All Unchanged Regions
diffEditor.collapseAllUnchangedRegions
Diff Editor: Show All Unchanged Regions
diffEditor.showAllUnchangedRegions
diffEditor.toggleCollapseUnchangedRegions
These three keyboard shortcuts are unbound by default and can be found by searching for "unchanged" in the Keyboard Shortcuts editor.
You can also use the mouse to fold or expand unchanged regions as shown in the demo below. Or double-click on the text nnn hidden lines
to unfold.
And also drag the sash bar just above or below the nnn hidden lines
text to reveal more of the hidden code.
And there is a toggle collapse/expand unchanged regions button when you have a diff open:
Upvotes: 3
Reputation: 2030
It's been implemented now. See this comment https://github.com/microsoft/vscode/issues/3562#issuecomment-1609725434
"diffEditor.experimental.useVersion2": true,
"diffEditor.experimental.collapseUnchangedRegions": true,
Upvotes: 12
Reputation: 169
This seems to be impossible in VS Code. The feature has been requested here: https://github.com/microsoft/vscode/issues/3562. But at the current moment, it hasn't been implemented yet.
Upvotes: 8