Reputation: 9779
When I open an svg or xml file and try to run "Format Document" I get the message:
There is no document formatter for 'xml'-files installed.
To overcome that I usually just do "Language Mode" -> select HTML -> "Format Document".
Is it possible to use the HTML formatter for XML and SVG?
P.S I rather not install extensions.
Upvotes: 16
Views: 22861
Reputation: 129
Sometimes when you open an SVG file in vscode all the content is on a single line. If you just want to do a basic reformat for visual inspection or printing, you can generate a reformatted file using PowerShell, like so:
$svgOriginal = 'C:\yourfolder\yourfile.svg'
$svgFormatted = 'C:\yourfolder\yourfile.txt'
Get-Content $svgOriginal | format-xml | out-file $svgFormatted -Encoding utf8
Open the output file in vscode, set the language mode to HTML and (if necessary) turn on word wrap (Alt + Z)
Upvotes: 0
Reputation: 2876
You should be able to override any extension to the language of your choice:
"files.associations": {
"*.xml": "html",
"*.svg": "html",
}
Chuck that in your settings.json
and you should be golden (although, I recommend not doing this, but it's your life)
Upvotes: 33