The XML extension, from Red Hat, supports auto-indentation on enter, among many useful other features (like validation, code completion, autoclose tag...):

format - XML autoformat in Visual Studio Code - Stack Overflow
Extension for automatic beautification of JSON, XML, etc.
XML formatting
Issues with prettier-vscode not working properly with plugins since prettier 3.1.0 release
Videos
I used to have some plug-in that on-pressing "Cmd+S" used to auto-detect file and beautify it. Can someone help me recall the name? Is it IntelliSense?
The code formatting is available in Visual Studio Code through the following shortcuts:
- On Windows Shift + Alt + F
- On Mac Shift + Option + F
- On Linux Ctrl + Shift + I
Alternatively, you can find the shortcut, as well as other shortcuts, through the submenu View / Command Palette, also provided in the editor with Ctrl + Shift + P (or Command + Shift + P on Mac), and then searching for format document.
For unsaved snippets
Open command palette (Win: F1 or Ctrl + Shift + P)
Find "Change Language Mode"
Select language e.g.
json. By now, the syntax should be highlighted.Format document (e.g. Open Command Palette -> "Format Document")
Unformat
- Select text
- Command Palette -> Join Lines
'Show the pics'


Code Formatting Shortcut:
Visual Studio Code on Windows - Shift + Alt + F
Visual Studio Code on MacOS - Shift + Option + F
Visual Studio Code on Ubuntu - Ctrl + Shift + I
You can also customize this shortcut using a preference setting if needed.
Code Formatting While Saving the File:
Visual Studio Code allows the user to customize the default settings.
If you want to auto format your content while saving, add the below code snippet in the work space settings of Visual Studio Code.
Menu File → Preferences → Workspace Settings
{
// Controls if the editor should automatically format the line after typing
"beautify.onSave": true,
"editor.formatOnSave": true,
// You can auto format any files based on the file extensions type.
"beautify.JSfiles": [
"js",
"json",
"jsbeautifyrc",
"jshintrc",
"ts"
]
}
Note: now you can auto format TypeScript files. Check my update.
I believe I have found a solution. Inside of the vscode settings file the following line needs to be added:
"prettier.documentSelectors": ["**/*.page"]
Per prettier vscode documentation found here: https://github.com/prettier/prettier-vscode#prettierdocumentselectors
'A list of glob patterns to register Prettier formatter. Typically these will be in the format of **/*.abc to tell this extension to register itself as the formatter for all files with the abc extension. This feature can be useful when you have overrides set in your config file to map custom extensions to a parser.'
I believe this is just telling prettier that it should run for any file that has an extension of 'page' which would be any visual force page. Hope this helps.
So I found a problem, but not sure it's the problem. The file associations were wrong, they needed a ".", then the file Language changed to HTML in the bottom bar and the formatter was able to handle them.
"files.associations": {
".component": "xml",
".page": "xml",
".cmp": "xml"
},
But I guess that's not the desired way to be. The prettierrc.json overrides don't seem to have any effect at all and I'd rather VF files said their language was Visualforce.
But gets the job done
» npm install @prettier/plugin-xml