首页 > 解决方案 > VS Code - 空行上的制表符大小

问题描述

我在 Visual Studio Code 中有以下设置:

"editor.tabSize": 4

"editor.insertSpaces": true

但是,当我删除一个新行并点击tab时,编辑器会插入 8 个空格:

在此处输入图像描述

我没有启用任何扩展。有没有我可以修改的设置,以便在上面的示例中仅插入 4 个空格?

更新

选项卡间距似乎受上面的行的影响。请看下面的动画。如果我的变量赋值行上方有一个带有花括号的方法,则按 Tab 键会达到我的预期并插入 4 个空格。

在此处输入图像描述

下面是 TypeScript 文件的一个子集以供参考。如果您注释掉product$andpipe函数,则制表符会插入我期望的空格数。

import { catchError, tap, map } from 'rxjs/operators';

export class ProductService {
    productsWithCategory$;
    productsUrl;

    // comment out starting on the line below
    products$ = this.http.get<Product[]>(this.productsUrl)
        .pipe(
            tap(data => console.log('Products: ', JSON.stringify(data))),
            catchError(this.handleError)
        );
    // to here

    selectedProduct$ = this.productsWithCategory$

}

标签: visual-studio-codevscode-settings

解决方案


推荐阅读