如何在 Visual Studio Code 中设置 `file.autoGuessEncoding` 的范围? [英] How can I set the range of `file.autoGuessEncoding` in Visual Studio Code?

查看:42
本文介绍了如何在 Visual Studio Code 中设置 `file.autoGuessEncoding` 的范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我可以在 vimrc 中设置编码的范围和顺序.这样,它会自动按顺序猜测文件的编码.

For example, I could set the range and order of encodings in vimrc. In this way, it automatically guesses the file's encoding in order.

set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

这在 Visual Studio Code 中可行吗?

Is this feasible in Visual Studio Code?

推荐答案

您可以在 VS Code 中更改此设置:

You can change this setting in VS Code:

// When enabled, will attempt to guess the character set encoding when opening files. This setting can be configured per language too.
"files.autoGuessEncoding": false,

但是当您将其设置为例如"ucs-bom,utf-8",你会得到一个工具提示,上面写着 Incorrect type.应为布尔值".

But when you set it to e.g. "ucs-bom,utf-8", you get a tooltip which says Incorrect type. Expected "boolean".

另一个与文件编码相关的设置是:

Another file-encoding related setting is this:

// The default character set encoding to use when reading and writing files. This setting can be configured per language too.
"files.encoding": "utf8"

但有效值是这些(当您尝试设置其他内容时可以看到这些):

But valid values are these (you can see these when you try to set something else):

"utf8", "utf8bom", "utf16le", "utf16be", "windows1252", "iso88591", "iso88593", "iso885915", "macroman", "cp437", "windows1256", "iso88596", "windows1257", "iso88594", "iso885914", "windows1250", "iso88592", "cp852", "windows1251", "cp866", "iso88595", "koi8r", "koi8u", "iso885913", "windows1253", "iso88597", "windows1255", "iso88598", "iso885910", "iso885916", "windows1254", "iso88599", "windows1258", "gbk", "gb18030", "cp950", "big5hkscs", "shiftjis", "eucjp", "euckr", "windows874", "iso885911", "koi8ru", "koi8t", "gb2312", "cp865", "cp850"

所以不,我认为你不能在 VS Code 中做到这一点,至少在没有扩展的情况下不能.(我不知道是否有这样的扩展可以使这成为可能.)但请注意,可以针对每种语言配置这两个设置.

So no, I don't think you can do that in VS Code, at least not without extensions. (I don't know if there is such an extension which would make this possible.) But do notice that those two settings can be configured per language.

这里有相关的 GitHub 问题,也许你应该权衡一下:

Here are relevant GitHub issues, maybe you should weigh in:

这篇关于如何在 Visual Studio Code 中设置 `file.autoGuessEncoding` 的范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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