更改原子打字稿中的制表符空间
问题描述:
当我们格式化代码时,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
答
至于建议的@baruch的内容,这里是参考:github.com/TypeStrong/atom-typescript/issues/1236
我张贴什么为我工作。
要更改缩进2 atom-typescript
:
- 转到您的项目目录。
- 打开或创建
tsconfig.json
。 -
添加以下代码
"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 }
这为我工作!
您是否在编辑器设置中检查过? – Baruch
是的,编辑器选项卡的长度设置为2. Atom - > preferences - > editor - > Tab Length – prranay
当我使用atom-typescript格式化代码时,它将标签空格从2更改为4. – prranay