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 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 three.js添加后处理以后模型锯齿化严重