Ariel Gabizon
Ariel Gabizon

Reputation: 3291

How to disable horizontal scroll in visual studio code?

When I scroll with the touch pad with two fingers in Visual Studio Code, I often scroll to the sides a little by accident. This is a bit annoying. I'd be happy to have it scroll only up and down.

Upvotes: 93

Views: 79608

Answers (11)

TheAngularGuy
TheAngularGuy

Reputation: 1079

If you have this problem because of Gitlens (blame lines), the solution i found is to disable gitlens.currentLine.scrollable (or set it to false in the settings json file).

Here is a direct issue for this: https://github.com/microsoft/vscode/issues/76458 and a more root cause one is at: https://github.com/microsoft/vscode/issues/32856

Upvotes: 68

WasiF
WasiF

Reputation: 28939

Pressing alt + z (windows) or ⌥ + z (mac) to disable/enable horizontal scrolling, works fine for a current single file.

If you want permanent solution for every file you visit? then follow:

Settings > Text Editor > Diff Editor > Word Wrap to on

enter image description here

Note: in case you don't know where is this Settings, just go

1. Via MENU

File > Preferences > Settings > Text Editor > Diff Editor > Word Wrap

2. Via shortcut Keys

On Windows

ctrl + , (control + comma)

On Mac

command + , (command + comma)

Upvotes: 30

halloleo
halloleo

Reputation: 10464

Late to the question, but because the in-VS-Code solutions were not to my liking I looked elsewhere:

If you are on a Mac with with Magic Mouse you can use BetterTouchTool to disable Horizontal Scrolling just for the Code app.

Upvotes: 0

Vlad Redko
Vlad Redko

Reputation: 111

I changed Word Wrap Column and saw scroll.

File > Preferences > Settings > Text Editor > Diff Editor > Word Wrap Column

enter image description here

Upvotes: 1

Ben Feng
Ben Feng

Reputation: 17

Use Ctrl + E, then Ctrl + W for disable horizontal scrolling.

For more details, you can refer this cite: https://developercommunity.visualstudio.com/t/disable-horizontal-scrolling-in-visual-studio-2019/612873.

Upvotes: -2

Eye Sight
Eye Sight

Reputation: 83

February 2020 (version 1.43) update adds an option called: Scroll Predominant Axis

Scrolling predominant axis

When trying to scroll vertically using a modern touchpad, it oftentimes happens that the file scrolls horizontally as well. There is now a new setting, editor.scrollPredominantAxis (which is set to true by default) which blocks "diagonal" scrolling. This forces scrolling gestures to be either vertical or horizontal (based on the highest absolute scroll delta), but never diagonal.

When enabled,it prevents any diagonal scrolling.
It guesses your scrolling to either vertical scroll or horizontal scroll
.

It says by default it is enabled. If not then you can enable in Scroll Predominant Axis in settings.

Screenshot: Editor: Scroll Predominant Axis

Or in settings.json

"editor.scrollPredominantAxis": true

Upvotes: 2

rickandmorty
rickandmorty

Reputation: 183

⌥ + z

the shortcut for Mac. you welcome

Upvotes: 6

iMujtaba8488
iMujtaba8488

Reputation: 251

Config: MBP 2018 | Using Magic Mouse 2.

For me, I had accidentally set the 'Scroll Beyond Last Column' to 80 chars. Just resetting it to default settings is what worked for me. Hope it does for you all!

enter image description here

Update (6th Feb, 2021): Enabling the mini-map again causes the problem. So disabled it to get rid of the issue.

Upvotes: 3

Anushil Kumar
Anushil Kumar

Reputation: 702

Just press ALT + Z -> To enable/disable the horizontal scroll

Upvotes: 10

DanielSmedegaardBuus
DanielSmedegaardBuus

Reputation: 1011

Just want to add that some plugins, like GitLens, may mess this setting up.

E.g., with GitLens, it can add git blame information inline, at the end of each line of code, showing you who is responsible for that line's current version, and when.

Unfortunately, this information will not only be to the right of the wrap column, e.g. 80, it'll also "unlock" the horizontal scrolling, even when no GitLens blame annotation is there.

I haven't found any fix for this other than disabling such features.

Upvotes: 9

Ariel Gabizon
Ariel Gabizon

Reputation: 3291

A partially satisfying solution, is to simply press Alt + z, to have the lines wrapped, and then it doesn't scroll to the side. You can also make wordWrap default as described here How do I turn on text wrapping by default in VS Code

Upvotes: 133

Related Questions