简体   繁体   English

vscode-go 输入选项卡的大小为 4 而不是 8

[英]vscode-go input tabs of size 4 instead 8

I have Visual Studio Code Insiders installed.我安装了Visual Studio Code Insiders Basically I've installed Go extension from Microsoft and written simple hello world app.基本上我已经安装了 Microsoft 的Go扩展并编写了简单的 hello world 应用程序。 Now I always use spaces to indent my code, but I saw that it changed to tabs of size 4. So I thought: yay, what a nice extension, now I can start to write my code.现在我总是使用空格来缩进我的代码,但我看到它变成了大小为 4 的制表符。所以我想:是的,多么好的扩展,现在我可以开始编写我的代码了。

Then I remembered, that the default code indent from gofmt should be 8 as tabs.然后我记得, gofmt的默认代码缩进应该是 8 作为制表符。 And I checked.我检查了。 gofmt main.go indeed outputs my code with tabs of size 8. But vscode keeps doing tabs of size 4. I thought maybe it doesn't even call gofmt but when I go RPM->Format document with - it actually does. gofmt main.go确实使用大小为 8 的选项卡输出我的代码。但是 vscode 一直在执行大小为 4 的选项卡。我想也许它甚至不会调用gofmt但是当我使用 RPM->Format 文档时 - 它实际上确实如此。 But still, tabs of size 4. What am I doing wrong in this scenario?但是,大小为 4 的标签。在这种情况下我做错了什么?

    "editor.renderWhitespace": "all",
    "editor.fontFamily": "Hack",
    "editor.fontSize": 12,
    "editor.minimap.enabled": false,
    "editor.fontLigatures": true,
    "workbench.editor.enablePreview": false,
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "editor.cursorSmoothCaretAnimation": true,
    "editor.detectIndentation": false

Those my only editor settings and I dont have any custom settings regarding Go extension那些我唯一的编辑器设置,我没有关于Go扩展的任何自定义设置

go fmt uses tab characters (" \\t ") to indent the beginning of a line. go fmt使用制表符(“ \\t ”)来缩进一行的开头。 How a tab is displayed (tab width) is up to your text editor or IDE.选项卡的显示方式(选项卡宽度)取决于您的文本编辑器或 IDE。 I have Tab Width set to 4 in my text editors.我在文本编辑器中将 Tab Width 设置为 4。 My terminal program uses a tab width of 8.我的终端程序使用的标签宽度为 8。

For example, for xed,例如,对于 xed,

Editor Preferences编辑器首选项

Tabs标签

Use the Tab width spin box to specify the width of the space that xed inserts when you press the Tab key.使用 Tab 宽度旋转框指定按 Tab 键时 xed 插入的空间宽度。

Select the Insert spaces instead of tabs option to specify that xed inserts spaces instead of a tab character when you press the Tab key.选择插入空格而不是制表符选项以指定 xed 在您按下 Tab 键时插入空格而不是制表符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM