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.
11 Answers
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

- 2,851
- 2
- 17
- 22
-
2If you don't want to use word wrap on long lines of code, you can use `shift+mousewheel` to scroll horizontally, or `shift+alt+mousewheel` which is faster. (This doesn't help the OP on a tablet, but I find it better on the desktop than using the horizontal scrollbar. – aamarks Jun 17 '19 at 21:18
-
Or just hit `home` twice to move to the start of the line. – aamarks Jun 17 '19 at 21:24
-
2On version 1.47.3 (Mac), enabling word wrap doesn't disable horizontal scrolling. The original problem still persists. This is due to Gitlens (see other answer). – spoulson Aug 10 '20 at 19:18
-
1For macOS Big Sur Version 11.5.2 `option+z` worked. – George Carvalho Sep 22 '21 at 19:59
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.

- 939
- 8
- 13
Pressing alt + z
to disable horizontal scrolling, works fine for a current single file. If you want permanent solution then for every file you visit? then follow:
Settings
> Text Editor
> Diff Editor
> Word Wrap
to on
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
- correct me if I am wrong
command + , (command + comma)

- 26,101
- 16
- 120
- 128
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.

- 977
- 1
- 10
- 18
-
4Think this should be a comment and not answer (or maybe even open a new question) – Ariel Gabizon Dec 18 '18 at 15:48
Just press ALT + Z -> To enable/disable the horizontal scroll

- 674
- 8
- 8
-
shortcut is used by nvdia geforce experience, do u know the exact setting of this, so that I can go manually toggle it – Time May 31 '23 at 15:25
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!
Update (6th Feb, 2021): Enabling the mini-map again causes the problem. So disabled it to get rid of the issue.

- 241
- 3
- 9
-
2For me default, 5, was still a problem, setting to 0 was the final pain relief :) – mPrinC Jun 29 '20 at 12:26
February 2020 (version 1.43) update adds an option called: Scroll 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

- 43
- 6
I changed Word Wrap Column and saw scroll.
File > Preferences > Settings > Text Editor > Diff Editor > Word Wrap Column

- 61
- 1
- 3
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.

- 9,216
- 13
- 64
- 122
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.

- 9