2017-10-16 66 views
0

當我們格式化代碼時,Atom打字稿將製表符空格從2改爲4。更改原子打字稿中的製表符空間

我改變formatting.js文件,並將其設置爲2而我依然面臨着同樣的問題..

我怎樣才能改變原子打字稿的標籤空間?下面

是formatting.js

"use strict"; 
Object.defineProperty(exports, "__esModule", { value: true }); 
/** 
* Maintainance: 
* When a new option is added add it to: 
* - the FormatCodeOptions interface 
* - the defaultFormatCodeOptions function 
* - the makeFormatCodeOptions function 
*/ 
const os_1 = require("os"); 
function defaultFormatCodeOptions() { 
    return { 
     baseIndentSize: 2, 
     indentSize: 2, 
     tabSize: 2, 
     newLineCharacter: os_1.EOL, 
     convertTabsToSpaces: true, 
     indentStyle: "Smart", 
     insertSpaceAfterCommaDelimiter: true, 
     insertSpaceAfterSemicolonInForStatements: true, 
     insertSpaceBeforeAndAfterBinaryOperators: true, 
     insertSpaceAfterKeywordsInControlFlowStatements: true, 
     insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, 
     insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, 
     insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, 
     insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, 
     insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, 
     placeOpenBraceOnNewLineForFunctions: false, 
     placeOpenBraceOnNewLineForControlBlocks: false, 
    }; 
} 
exports.defaultFormatCodeOptions = defaultFormatCodeOptions; 
//# sourceMappingURL=formatting.js.map 
+0

您是否在編輯器設置中檢查過? – Baruch

+0

是的,編輯器選項卡的長度設置爲2. Atom - > preferences - > editor - > Tab Length – prranay

+0

當我使用atom-typescript格式化代碼時,它將標籤空格從2更改爲4. – prranay

回答

0

至於建議的@baruch的內容,這裏是參考:github.com/TypeStrong/atom-typescript/issues/1236

我張貼什麼爲我工作。

要更改縮進2 atom-typescript

  1. 轉到您的項目目錄。
  2. 打開或創建tsconfig.json
  3. 添加以下代碼

    "formatCodeOptions": { 
        "baseIndentSize": 0, 
        "indentSize": 2, 
        "tabSize": 2, 
        "newLineCharacter": "\n", 
        "convertTabsToSpaces": true, 
        "indentStyle": "Smart", 
        "insertSpaceAfterCommaDelimiter": true, 
        "insertSpaceAfterSemicolonInForStatements": false, 
        "insertSpaceBeforeAndAfterBinaryOperators": true, 
        "insertSpaceAfterConstructor": false, 
        "insertSpaceAfterKeywordsInControlFlowStatements": true, 
        "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, 
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, 
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, 
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false, 
        "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, 
        "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false, 
        "insertSpaceBeforeFunctionParenthesis": false, 
        "placeOpenBraceOnNewLineForFunctions": false, 
        "placeOpenBraceOnNewLineForControlBlocks": false 
    } 
    

這爲我工作!