fabianlauer / vs-code-xml-format Goto Github PK
View Code? Open in Web Editor NEWSimple XML formatter for Visual Studio Code.
Home Page: https://marketplace.visualstudio.com/items/fabianlauer.vs-code-xml-format
License: MIT License
Simple XML formatter for Visual Studio Code.
Home Page: https://marketplace.visualstudio.com/items/fabianlauer.vs-code-xml-format
License: MIT License
Hi!
Firstly, thanks for this simple, little extension. I'm using it for an Ionic2 project where an XML gets generated when running certain commands. For some reason it's always generated a bit differently and makes a mess out of commits. The biggest difference seems to be the order of attributes. It would be nice if the formatter would consistently order these attributes the same way, so I could format the file if there are any changes and get a clearer view of what actually changed.
I have a tag which as many attributes. Currently this is formatted to one long line where I have to scroll for reading the whole thing. It would be nice if the formatter could break the line into multiple ones.
Current result after formatting:
<View controllerName="opensap.manageproducts.controller.Object" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" xmlns:form="sap.ui.layout.form" xmlns:semantic="sap.m.semantic">
Required result:
<View controllerName="opensap.manageproducts.controller.Object" xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" xmlns:form="sap.ui.layout.form"
xmlns:semantic="sap.m.semantic">
Maybe you can make use of a global line length value in VS code?
Thanks for your work!
Long XML files are not formatted.
Steps:
The option doesn't even show. The same XML can be formatted in Sublime.
First of all, great extension! ๐
If you have comments inside the XML file, they are removed. It doesn't matter if the comments are commented nodes or simply simple comments.
Thanks in advance.
Formatting seems to rip out anything after and including a as well as a node that is self closed
With this extension enabled, running the Build Task is no longer automatically opens the OUTPUT window in vscode. By simply disabling this extension, the OUTPUT window is opened as expected.
Hi Fabian !
I just installed your plugin for VS Code 1.20.1 on Windows 10 64 bits. First of all, it wasn't Ctrl+Alt+P that brought me the console but Ctrl+Shift+P, then when I typed 'Format Code', no command was found, well, because it's rather 'Format Document' (mapped to Shift+Alt+F).
You may have to change your Readme file.
Hello,
the 0.1.1 update seems to work pretty well and addresses some of the previous issues.
But there is one thing now that I'd like to be how it was in the previous version:
So the values all get a new line which is not the usual way a xml looks like in my understanding: http://www.w3schools.com/xml/
Maybe this could even lead to reading errors? (Trailing whitespace and stuff, I don't know)
But it would come in handy to have some option to change this behaviour.
Installed this plugin (and reloaded), but on Mac, Shift
+CMD
+P
the Format Code
command does not exist.
<a>xxx</a>
Is formatted:
<a>
xxx
</a>
Which adds thousands of lines to the XML.
Hello,
I did install the extension on MAC OS X. Extension installed, restarted, but Cmd+Shift+P do not list "Format Code". Any clue?
Thanks, Yves
Perhaps I can modify a setting, but in the event anyone else has an issue, when opening and adding code directly to a .NET Core .csproj file, on save the formatting breaks and during dotnet restore the following error is thrown as it adds hard returns and spaces around portions of code.
C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: The expression "[System.IO.Path]::GetFullPath(C:\test\obj\Debug\ [C:\test\test.csproj]
C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: netcoreapp1.1 [C:\test\test.csproj]
C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: \PubTmp)" cannot be evaluated. Illegal characters in path. Parameter name: path [C:\test\test.csproj]
If I have an XML document like this:
<?xml version="1.0" encoding="utf-8"?>
<Foo xmlns:f="http://foo.com/ns" xmlns="urn:epcglobal:epcis:xsd:1">
<Element xmlns="">
<Parent>
<f:Other>
</f:Other>
</Parent>
</Element>
</Foo>
And I then format it, it looks like this (notice the missing f:
prefix on Other
):
<?xml version="1.0" encoding="utf-8"?>
<Foo xmlns:f="http://foo.com/ns" xmlns="urn:epcglobal:epcis:xsd:1">
<Element xmlns="">
<Parent>
<Other>
</Other>
</Parent>
</Element>
</Foo>
This is obviously a contrived example, but we are dealing with an external company which embeds an element of their own namespace inside an element in a different namespace. VS 2017 handles this without issue.
An attribute like:
<absPath url="D:\Users\kgunders\Documents\MR\Projects\HyperLinkSheets"
Will cause the following error:
XML formatting failed: at line 2, column 694: namespace prefix must be followed by a tag name.
Here is more context from the problematic XML:
<Choice Requires="x15">
<absPath url="D:\Users\kgunders\Documents\MR\Projects\HyperLinkSheets\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac" />
</Choice>
A work around is to temporarily add a character after the backslash, format, and remove the extra character.
Instead of adding a new commend, better add yourself as a formatter provider
vscode.languages.registerDocumentFormattingEditProvider('xml', ...)
vscode.languages.registerDocumentRangeFormattingEditProvider('xml', ...)
Yes then get invoked on the built-in Format command.
You can have a look at my css formatter extension:
https://github.com/aeschli/vscode-css-formatter/
Almost like Issue #6.
A node like
<system.webServer>
<!-- .... -->
</system.webServer>
Will cause an error and will not format the document.
XML formatting failed: at line #, column #; expected whitespace or end of opening tag.
Work around would be to simply remove the period from the nodes, format the document, then add them back.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.