dongxun1244 2019-07-27 15:52
浏览 15
已采纳

vscode-go输入标签的大小为4而不是8

I have Visual Studio Code Insiders installed. Basically I've installed Go extension from Microsoft and written simple hello world app. 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.

Then I remembered, that the default code indent from gofmt should be 8 as tabs. 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. But still, tabs of size 4. What am I doing wrong in this scenario?

    "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

  • 写回答

1条回答 默认 最新

  • dsgoj7457 2019-07-27 16:07
    关注

    go fmt uses tab characters ("\t") to indent the beginning of a line. How a tab is displayed (tab width) is up to your text editor or IDE. I have Tab Width set to 4 in my text editors. My terminal program uses a tab width of 8.

    For example, for 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码