如何自定义制表符到空格的转换系数? [英] How can I customize the tab-to-space conversion factor?

查看:23
本文介绍了如何自定义制表符到空格的转换系数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 Visual Studio Code 时如何自定义制表符到空格的转换系数?

How do I customize the tab-to-space conversion factor when using Visual Studio Code?

例如,现在在 HTML 中,每次按 TAB 似乎会产生两个空格,但在 TypeScript 中它会产生 4.

For instance, right now in HTML it appears to produce two spaces per press of TAB, but in TypeScript it produces 4.

推荐答案

默认情况下,Visual Studio Code 将尝试根据您打开的文件猜测您的缩进选项.

By default, Visual Studio Code will try to guess your indentation options depending on the file you open.

您可以通过 "editor.detectIndentation": false 关闭缩进猜测.

You can turn off indentation guessing via "editor.detectIndentation": false.

您可以通过菜单文件首选项用户设置中的这三个Windows设置轻松自定义此设置对于 Mac,在菜单 CodePreferencesSettings⌘,:

You can customize this easily via these three settings for Windows in menu FilePreferencesUser Settings and for Mac in menu CodePreferencesSettings or ⌘,:

// The number of spaces a tab is equal to. This setting is overridden
// based on the file contents when `editor.detectIndentation` is true.
"editor.tabSize": 4,

// Insert spaces when pressing Tab. This setting is overriden
// based on the file contents when `editor.detectIndentation` is true.
"editor.insertSpaces": true,

// When opening a file, `editor.tabSize` and `editor.insertSpaces`
// will be detected based on the file contents. Set to false to keep
// the values you've explicitly set, above.
"editor.detectIndentation": false

这篇关于如何自定义制表符到空格的转换系数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆