1. 程式人生 > 其它 >vscode設定go語言中tab為空格

vscode設定go語言中tab為空格

1.點選Manage->Settings,輸入Editor: Insert Spaces 2.出現go配置,點選Edit in settings.json

輸入editor,在聯想的下拉框中,出現editor.insertSpaces,輸入回車,檔案中會自動生成下面的文字

"[go]":{ "editor.insertSpaces":true, "editor.snippetSuggestions":"none", "editor.formatOnSave":false, "editor.codeActionsOnSave":{ "source.organizeImports":true } }, 設定editor.insertSpaces的值為true,儲存檔案。再編輯go檔案,發現按下Tab鍵,會變成空格。 完整的settings.json檔案如下:
{
    "go.useLanguageServer": true,
    "timeline.excludeSources": [],

    "[go]": {
        "editor.insertSpaces": true,    
        "editor.snippetSuggestions": "none",
        "editor.formatOnSave": false,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        }
    },
    "go.autocompleteUnimportedPackages": true,
    "go.formatTool": "goformat",
    "gopls": {
        "completeUnimported": true,
        "usePlaceholders": true,
        "completionDocumentation": true,
        "deepCompletion": true, 
        "matcher": "fuzzy",
        "hoverKind": "SynopsisDocumentation" // No/Synopsis/Full, default Synopsis
    },
    
    "files.eol": "\n", // formatting only supports LF line endings

    "go.languageServerExperimentalFeatures": {
        "format": true,
        "autoComplete": true,
        "rename": true,
        "goToDefinition": true,
        "hover": true,
        "signatureHelp": true,
        "goToTypeDefinition": true,
        "goToImplementation": true,
        "documentSymbols": true,
        "workspaceSymbols": true,
        "findReferences": true,
        "diagnostics": false
    },
    "emmet.excludeLanguages": [
    
        "markdown"
    ],
    "go.addTags": {
    
    },
    "go.gotoSymbol.includeImports": true,
    "editor.detectIndentation": false,
    "editor.autoIndent": "keep",
    "editor.formatOnSave": true,
    "editor.formatOnType": true
}