如何使 VSCode 编辑器停止滚动过去的文件底部?

在 VSCode 编辑中,当您将 滚动条拉到文件底部时,您看到的只是一个 空白页,因为文本已经向上滚动到文本编辑器窗口的 头儿。这使得滚动到底部的 很难,因为你不能只是拉动滚动条快速所有的方式下来,但必须小心定位光标,以便您仍然可以看到您的代码。

非常类似于 如何使 VisualStudio 编辑器停止滚动过去的文件底部?,但是评论指出问题/答案是针对 Visual Studio 的。这个答案适用于 macOS 和 Windows 上的 VSCode。

13471 次浏览

The correct answer is seen here: https://stackoverflow.com/a/40588828/1189470

There is a configuration option provided in VSCode for the functionality you specified. To enable it, go to File -> Preferences -> user settings

On the right side of the editor in settings.json paste the below line at the bottom (before closing bracket), save and close.

"editor.scrollBeyondLastLine": false

This will prevent the editor from scrolling beyond the last line.

This is now exposed as a simple checkbox labeled "Editor: Scroll Beyond Last Line" in File/Apple -> Preferences.

If just for readability you would like some space at the bottom of the file - a configurable amount - try this setting as of v1.43:

editor.padding.bottom in pixels

Editor> Padding: Bottom

Controls the amount of space between the bottom edge of the editor and the last line.

and/or

editor.padding.top // but this isn't sticky in the sense that you can scroll right past the padding top and it is gone. It doesn't stay.