Skip to content

Pretty XML is a XML Formatter extension for Visual Studio Code

License

Notifications You must be signed in to change notification settings

pmahend1/PrettyXML

Repository files navigation

Pretty XML

What is it?

Features
1. Prettify XML (XML Formatting)
2. Pretty XML: Minimize

Keyboard Shortcuts

Settings

Requirements

Installation

Known Issues

Change Log

For more information

What is it?

Pretty XML is a XML formatter extension for Visual Studio Code and VSCodium. It formats XML documents just like Visual Studio on Windows.

Supported file extensions:

  • xml
  • xaml
  • axml
  • xsd
  • xsl
  • plist
  • mobileconfig
  • config
  • csproj
  • svg
  • resx and all other XML type of files.

There is also Visual Studio for Mac version of this extension. Check it out at PrettyXML.VSMac

Suggestions, improvement PRs are welcome.

LicenseDeploy

Visual Studio Marketplace VersionVisual Studio Marketplace InstallsVisual Studio Marketplace DownloadsVisual Studio Marketplace Rating

Open VSXOpen VSX DownloadsOpen VSX Rating

prettify gif.


Features

1. Prettify XML (XML Formatting)

Right Click and Select Prettify XML or use shortcut

  • Position each attribute on a separate line.
  • First attribute on same line as start element start tag.
  • All attributes indented aligning with first attribute.
  • If no child for an element then close inline end tag.
  • No empty lines.
  • Supports ' and whitespace unicodes in attribute value for XAML parser compatibility.

Before

Before.

After

After.

2. Pretty XML: Minimize

Minimizes XML.

minimize gif.


Keyboard Shortcuts

Command Platform Shortcut
Prettify XML Mac Cmd+K L
Prettify XML Windows, Linux Control+K L
PrettyXML: Minimize Mac Cmd+K `
PrettyXML: Minimize Windows, Linux Control+K `

Note

You can change these in Preferences → Keyboard Shortcuts if you want.


Settings

These will be for Prettify XML command.

Setting Key Default Value Description
prettyxml.settings.indentSpaceLength 4 No. of spaces for indentation.
prettyxml.settings.useSingleQuotes false Use ' instead of "
prettyxml.settings.useSelfClosingTag true If no child nodes then self closing tag />
prettyxml.settings.formatOnSave false Enable format on save
prettyxml.settings.allowSingleQuoteInAttributeValue true Allows ' in attribute values instead of '
prettyxml.settings.addSpaceBeforeSelfClosingTag true Adds space before self closing tag
prettyxml.settings.wrapCommentTextWithSpaces true Wraps comment text with a single space
prettyxml.settings.allowWhiteSpaceUnicodesInAttributeValues true Allows white space unicodes in attribute values
prettyxml.settings.positionFirstAttributeOnSameLine true Position first attribute on same line.
prettyxml.settings.positionAllAttributesOnFirstLine false Position all attributes on first line
prettyxml.settings.preserveWhiteSpacesInComment false Preserves whitespaces in a comment.
prettyxml.settings.addSpaceBeforeEndOfXmlDeclaration false Add space before end of XML declaration.
prettyxml.settings.attributesInNewlineThreshold 1 Attributes count threshold to position attributes in newlines.
prettyxml.settings.enableLogs false Enables logs

Settings Image.

Attributes In Newline Threshold

Example:

Value = 2

Input#1

<Element Attribute1="Value1" Attribute2="Value2" />

Output#1

<Element Attribute1="Value1" Attribute2="Value2" />

Input#2

<Element Attribute1="Value1" Attribute2="Value2" Attribute3="Value3" />

Output#2

<Element Attribute1="Value1"
         Attribute2="Value2"
         Attribute3="Value3"/>

Requirements


Installation

Visual Studio Code - Visual Studio MarketPlace

For VSCodium - open-vsx.org


Known Issues

  • Limited DTD support.
  • Formats valid XML files only. Syntax errors are displayed.

Issues can be reported at issues section


For more information

About

Pretty XML is a XML Formatter extension for Visual Studio Code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published