vscode-输入大小为 4 而不是 8 的制表符
vscode-go input tabs of size 4 instead 8
我已经安装了 Visual Studio Code Insiders
。基本上我已经安装了 Microsoft 的 Go
扩展并编写了简单的 hello world 应用程序。现在我总是使用空格来缩进我的代码,但我看到它变成了 4 号制表符。所以我想:耶,多么好的扩展,现在我可以开始编写我的代码了。
然后我想起来了,gofmt
的默认代码缩进应该是 8 个制表符。我检查了。 gofmt main.go
确实输出了我的代码,标签大小为 8。但是 vscode 一直在做大小为 4 的标签。我想也许它甚至没有调用 gofmt
但是当我进入 RPM->Format 时文档 - 它确实如此。但仍然是 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
这些是我唯一的编辑器设置,我没有关于 Go
扩展程序的任何自定义设置
go fmt
使用制表符 ("\t
") 缩进行首。选项卡的显示方式(选项卡宽度)取决于您的文本编辑器或 IDE。我在我的文本编辑器中将 Tab Width 设置为 4。我的终端程序使用制表符宽度 8。
例如,对于 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.
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.
我已经安装了 Visual Studio Code Insiders
。基本上我已经安装了 Microsoft 的 Go
扩展并编写了简单的 hello world 应用程序。现在我总是使用空格来缩进我的代码,但我看到它变成了 4 号制表符。所以我想:耶,多么好的扩展,现在我可以开始编写我的代码了。
然后我想起来了,gofmt
的默认代码缩进应该是 8 个制表符。我检查了。 gofmt main.go
确实输出了我的代码,标签大小为 8。但是 vscode 一直在做大小为 4 的标签。我想也许它甚至没有调用 gofmt
但是当我进入 RPM->Format 时文档 - 它确实如此。但仍然是 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
这些是我唯一的编辑器设置,我没有关于 Go
扩展程序的任何自定义设置
go fmt
使用制表符 ("\t
") 缩进行首。选项卡的显示方式(选项卡宽度)取决于您的文本编辑器或 IDE。我在我的文本编辑器中将 Tab Width 设置为 4。我的终端程序使用制表符宽度 8。
例如,对于 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.
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.