是否有可能显示空白字符,像空格字符,在Visual Studio代码?

在设置中似乎没有这个选项。json(虽然它是Atom.io中的一个选项),我还不能使用CSS显示空白字符。


当前回答

使空白可见的选项现在显示为视图菜单上的一个选项,如Visual Studio Code版本1.15.1中的“Toggle Render whitespace”。

其他回答

从VSCode 1.75(2023年1月)开始,空格和制表符再现将不会像今天一样受到样式/颜色的影响,如49462期报道的那样:

之前1.75:

PR 168732提出了一个新的实验性whitespacerendering设置:

svg:使用svgs的新渲染方法 font:使用新的字体字符渲染方法 off:使用稳定渲染方法

现在(2022年12月)可以在VSCode内部使用。

为了让diff显示空白类似于git的diff设置diffEditor。ignoreTrimWhitespace为false。编辑。renderWhitespace的帮助很小。

// Controls if the diff editor shows changes in leading or trailing whitespace as diffs
"diffEditor.ignoreTrimWhitespace": false,

若要更新设置,请转到

>首选项>用户设置 Mac用户注意:“首选项”菜单在“代码”而不是“文件”下面。为 例如,代码>首选项>用户设置。

这将打开一个名为“默认设置”的文件。展开//Editor区域。现在你可以看到所有这些神秘的编辑器。*设置已定位。搜索(CTRL + F) renderWhitespace。我的盒子上写着:

// Controls how the editor should render whitespace characters, posibilties are 'none', 'boundary', and 'all'. The 'boundary' option does not render single spaces between words.
"editor.renderWhitespace": "none",

更让人困惑的是,左边的“默认设置”窗口是不可编辑的。你需要使用标题为“settings.json”的窗口覆盖它们。你可以从“Default settings”复制粘贴设置到“settings.json”:

// Place your settings in this file to overwrite default and user settings.
{
     "editor.renderWhitespace": "all",
     "diffEditor.ignoreTrimWhitespace": false
}

我最终关闭了renderWhitespace。

只是为了演示编辑器的变化。renderWhitespace: none||boundary||all will do to your VSCode我添加了这张截图: .

其中Tab是→和Spaceare。

使空白可见的选项现在显示为视图菜单上的一个选项,如Visual Studio Code版本1.15.1中的“Toggle Render whitespace”。

打开用户首选项。键盘快捷键:CTR + SHIFT + P ->首选项:打开用户设置; 在搜索字段中插入空白,并选择所有参数