I am having trouble viewing files with .png encoding without the .png file extension in Visual Studio Code. It will only show the warning "The file is not displayed because it is either binary or uses an unsupported text encoding.". Trying to select an editor only provides the options "text" or "hex".
So, is it possible to change the file association of a given file extension to inform VS Code to render that file as a .png, or other image type?
I have tried adding the lines "files.associations": { "*.otherfiletype": "png" }
to my settings.json, but this has no effect.
2
Answers
You can use the
workbench.editorAssociations
setting. Ex. in settings.json:It will still give a warning that
But the change will allow you to click the "Open Anyway" button and be presented with the option to open it with the "Image Preview" (builtin) custom editor.
Visual Studio Code (VS Code) is primarily designed as a text editor and does not inherently support viewing image files like .png files directly within the editor. The "files.associations" configuration in VS Code settings is meant for associating file extensions with specific programming languages, not for rendering images.
However, you can achieve your goal using a VS Code extension called "Image Preview" which allows you to preview image files within the editor.
Find the "Image Preview" extension by Kamesh Kotwani and click the "Install" button.