How to disable svg preview in VS Code 1.97+ - Stack Overflow

admin2025-04-24  3

This is the issue I am facing:

SVGs have begun to open as regular files, which I do not need, I would like to view them as HTML markup.

I do not know how this has happened. I haven't made any changes to my VS Code, I haven't installed any extensions recently and the day before yesterday this working was fine.

This is the issue I am facing:

SVGs have begun to open as regular files, which I do not need, I would like to view them as HTML markup.

I do not know how this has happened. I haven't made any changes to my VS Code, I haven't installed any extensions recently and the day before yesterday this working was fine.

Share Improve this question edited Mar 12 at 10:19 pjpscriv 1,3181 gold badge16 silver badges30 bronze badges asked Jan 16 at 23:28 user24302837user24302837 5314 silver badges3 bronze badges 3
  • hi, the question is good, you should accept a correct answer so that the community can use the solution given to you ... (nnatali worked for me) – webman Commented Feb 24 at 5:46
  • 1 What an absolute sh** change. At least they should have an easy switch between preview and code – nanobar Commented Apr 9 at 8:00
  • Feature request for improving this behavior: github.com/microsoft/vscode/issues/239834 (but please avoid commenting there, it already has suggestions and workarounds mentioned in the comments) – Marcono1234 Commented Apr 13 at 10:16
Add a comment  | 

3 Answers 3

Reset to default 74

It's a new feature for last version. I prefer to see the XML markup too.

I found your post looking for how to disable it, but I found the solution in another website.

Go to settings, search for workbench.editorAssociations and add item with key: *.svg and value: default

Screenshot:

VS Code was recently updated to render SVG files as previews by default.

Paste this in your settings.json to disable the feature:

"workbench.editorAssociations": {
    "*.svg": "default"
}

You must be using the Insiders Build as there was a recent commit that enabled previewing svg's just like other "images".

You can do one of two things.

  1. Right-click on the file in the Explorer and choose Open With... and then select the Text Editor option and you should get the svg code.

  2. You can set the default to be to open svg files in a text editor instead of an image preview from that same context menu. Choose the Configure default editor for *.svg files and it will always open in a text editor thereafter.

转载请注明原文地址:http://anycun.com/QandA/1745499202a90785.html