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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With