Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically format XAML code in Visual Studio?

Here:

https://social.msdn.microsoft.com/Forums/de-DE/b77c7529-298f-4b9a-874a-f94f699986ac/automatically-formatting-xaml-code?forum=vswpfdesigner

... it is written that one can use "Ctrl+K+D" ... but that didn't work.

I also tried "shift + alt + F", which was suggested here:

How do you format code in Visual Studio Code (VSCode)

... it didn't work either.

So my question is: how can you automatically format XAML code in Visual Studio?

like image 724
steady_progress Avatar asked Sep 10 '17 20:09

steady_progress


People also ask

How do I Auto beautify code in Visual Studio?

Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.

How do I automatically format code in Visual Studio Code?

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.

What is the fastest way to format code in Visual Studio?

In the default configuration for Visual Studio Code, the command can be run using the shortcut Alt+Shift+F. To format a range, in an already opened project, open the document that you want to modify, select the specific range to format, right-click, and select Format Selection.


1 Answers

Probably your formatting options are wrong, go to: Tools -> Options -> Text Editor -> XAML -> Formatting -> Spacing and on Attribute Spacing section click "Position each attribute on a separete line" and then try "Ctrl+K+D" again.

like image 97
stanimirsp Avatar answered Oct 20 '22 15:10

stanimirsp