简体   繁体   中英

Keybinding for Format Code -> Shift+Alt+F in VS Code does not seem to work

On this link the following keybinding is described:

在此处输入图片说明

What I need is the ability to load an XML and have it properly formatted, as you would with Ctrl + K + D in visual studio.

I had prepared this xml content:

<root><level1><sublevel1A></sublevel1A><sublevel1B></sublevel1B></level1><level2><sublevel2A></sublevel2A></level2></root>

Which would need to be formatted to this:

<root>
    <level1>
        <sublevel1A>
        </sublevel1A>
        <sublevel1B>
        </sublevel1B>
    </level1>
    <level2>
        <sublevel2A>
        </sublevel2A>
    </level2>
</root>

Nothing happens though if I use the key binding. Nor does it help if I select everything first.

Any ideas?

There is no built-in support for XML formatting in VSCode. To get XML formatting you need install this extension - https://marketplace.visualstudio.com/items?itemName=fabianlauer.vs-code-xml-format


Also, you have a typo in your example XML, </subleve1B> instead of </sublevel1B>

The XML extension from Red Hat provides, among many other features, formatting support for XML document: 格式化XML

It requires a JDK >= 8 to run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM