消除了在 V.S 中向右滚动的需要。代码编辑器

Eliminating the need for scrolling right in the V.S. Code editor


如何配置 V.S。在视口结束前换行的代码?


V.S。 Code 将长行的末尾放在 viewport 之外,换句话说;当一行的长度超过编辑器 viewport 的长度时,编辑器将该行放在一个不可见的区域,导致我不得不一直向右滚动才能看到我输入的整个脚本——它是非常适得其反。我想通过配置 V.S 完全消除向右滚动的需要。代码适应app的大小,根据编辑器viewport.

的宽度从上到下

这是一张演示该问题的照片:

It demonstrates how I have to keep scrolling right to view the entirty of a line that exceeds the length of the viewport.


消除 VS-Code 编辑器中的水平滚动

This topic (or question) is more involved than some people might think. Below are the settings that I suggest using to eliminate horizontal scrolling, and for wrapping lines at the viewport. Some of the settings may seem odd, but it is important to include all settings that affect what ever it is your trying to configure, in this case, line wrapping, tab wrapping, and horizontal scrolling. All of the settings that I have added to my example are explained below the code block — I describe every setting that I include.

Configuring V.S. Code in such a way, that the need for horizontal scroll bars (or for scrolling horizontally) is eliminated altogether, the editor will need to be configured so that lines wrap at the viewport, and tabs too will wrap at the viewport. Any settings below that do not achieve this, are configured to make sure that the configuration is not overridden by related settings. If some of the settings look familiar, it is because some of them were only released with-in the last 3-4 months (current month "August of 2021").

开始

I am guessing that when you asked the question, that you were only referring to horizontal scrolling within the editor when you asked how to get rid of horizontal scrolling, its important to note, and many of you likely know this already, but the editor is not the only part of V.S. Code that is vulnerable to becoming overcrowded, and forcing content out of the visible viewport. Tabs are also prone to this behavior. IMO, the V.S. Code U.I. was screwed-up when horizontal scrolling was added to it as a way of solving over crowdedness in the editor, fortunately however; V.S. Code has a fantastic devs-team, it seems to enjoy listening to the community that it has. The team has eliminated the need to use horizontal scrolling by adding features that present an alternate way of handling an overcrowded editor.




V.S。代码:配置编辑器以更好地包裹,当视口太小,或编辑器过于拥挤时。

_        To configure V.S. Code, so that your lines of code, and your tabs, both wrap just before they reach the end of the visible viewport at the right side of your screen, you will need to insert the settings — as well as the values that are assigned to them, exactly as seen below — to the appropriately scooped ".../settings.json" file._





    // "./.vscode/settings.json" || ".../user/settings.json"   

    {
        "workbench.editor.wrapTabs": true
        "editor.wordWrap": "on",  
        "diffEditor.wordWrap": "inherit",
        "editor.scrollbar.horizontal": "hidden",   ​
        "editor.accessibilitySupport": "off"
   ​}



以上设置的简要说明:

workbench.editor.wrapTabs:正确 在
继承 隐藏

V.S. Code Settings ASSIGNED VALUE DECRIPTION
workbench.editor.wrapTabs "True" "When a tab would normally be forced out of the viewport, it is placed on a new row that exists between the breadcrumbs and the preexisting row of tabs."
ed​itor.wordWrap "On" "When set to on, Lines wrap at the viewport width. Setting it to off will make it so lines continue on, past the visible viewport, until you start writing code on a new line."
diffEditor.wordWrap "Inherit" "Enables the standard editor's wordWrap configuration, for the Diff.Editor. Enabling this makes it so editors all work as expected, without needed to unnecessarily assign values to more settings than is needed (or practice)."
editor.scrollbar.horizontal "Hidden" "Sometimes the horizontal scroll bar can pop up, despite there being no need for it. This setting makes sure it remains hidden at all times."
editor.accessibilitySupport "Off" "Controls whether the editor should use support for features that can help people who may have difficulties from age, disabilities, or other reasons for needing accessibilitySupport. When set to "on" V.S. Code disables word Wrapping, and allows for lines of code to be placed outside of the visible viewport, as it optimizes the editor for screen readers. If you don't need the support, it should be set to off."


要详细了解此答案中的设置,请转到:
https://code.visualstudio.com/docs/getstarted/settings#_languagespecific-editor-settings