Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Visual Studio Code to detect and set the correct encoding on file open

I recently started to use Visual Studio Code on Server Systems where I did not have Studio IDE installed. I like it very much but I'm running into a problem.

When I open a file (used Notepad++ before) the editor detects the encoding and sets it for me. I have many files on windows servers that are still with windows-1252 but vscode just uses UTF-8 by default.

I know I can reopen with encoding Western (Windows 1252) but I often forget it and I have sometimes destroyed some content while saving it.

So I did not find any parameter yet, is there a way to make vscode detect the encoding and set it automatically when I open a file?

like image 810
YvesR Avatar asked Jul 22 '16 14:07

YvesR


People also ask

How do I check the encoding of a file in Visual Studio?

In the Open With dialog box, choose the editor to open the file with. Many Visual Studio editors, such as the forms editor, will auto-detect the encoding and open the file appropriately. If you choose an editor that allows you to choose an encoding, the Encoding dialog box is displayed.

How do I change the encoding of a file in VSCode?

In the bottom bar of VS Code, you'll see the label UTF-8. Click it to open the action bar and select Save with encoding. You can now pick a new encoding for that file. See VS Code's encoding for full instructions.

How do I change the default encoding in Visual Studio?

Now open one of your files in Visual Studio. To verify its saving as UTF-8 go to File > Save As, then under the Save button choose "Save With Encoding". It should choose "UNICODE (Save without Signature)" by default from the list of encodings.


1 Answers

To allow Visual Studio Code to automatically detect the encoding of a file, you can set "files.autoGuessEncoding":true (in the settings.json configuration file).

https://github.com/Microsoft/vscode/pull/21416

This obviously requires an updated verison of the application compared to when the question was originally asked.

like image 177
SleepyFox89 Avatar answered Sep 23 '22 07:09

SleepyFox89