Skip to content

Commit 6d7c9cc

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/visualstudio-docs-pr (branch live)
2 parents ac70f6e + 3740165 commit 6d7c9cc

File tree

6 files changed

+89
-129
lines changed

6 files changed

+89
-129
lines changed

.openpublishing.redirection.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
"redirect_url": "/visualstudio/msbuild/msbuild",
66
"redirect_document_id": false
77
},
8+
{
9+
"source_path": "docs/ide/reference/options-text-editor-xml-formatting.md",
10+
"redirect_url": "/visualstudio/xml-tools/options-text-editor-xml-formatting",
11+
"redirect_document_id": false
12+
},
13+
{
14+
"source_path": "docs/ide/reference/options-text-editor-xml-miscellaneous.md",
15+
"redirect_url": "/visualstudio/xml-tools/options-text-editor-xml-formatting",
16+
"redirect_document_id": false
17+
},
818
{
919
"source_path": "docs/ide/reference/options-text-editor-xaml-formatting.md",
1020
"redirect_url": "/previous-versions/visualstudio/visual-studio-2017/ide/reference/options-text-editor-xaml-formatting",

docs/ide/reference/options-text-editor-xml-formatting.md

Lines changed: 0 additions & 66 deletions
This file was deleted.

docs/ide/reference/options-text-editor-xml-miscellaneous.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

docs/toc.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -988,12 +988,6 @@
988988
href: ide/reference/options-text-editor-fsharp-code-fixes.md
989989
- name: IntelliSense
990990
href: ide/reference/options-text-editor-fsharp-intellisense.md
991-
- name: XML
992-
items:
993-
- name: Formatting
994-
href: ide/reference/options-text-editor-xml-formatting.md
995-
- name: Miscellaneous
996-
href: ide/reference/options-text-editor-xml-miscellaneous.md
997991
- name: Windows Forms Designer
998992
href: ide/reference/options-windows-forms-designer.md
999993
- name: XAML Designer
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: Configure formatting in the XML editor
3+
description: Learn how to configure XML formatting and miscellaneous options in the Visual Studio text editor.
4+
ms.date: 9/23/2025
5+
ms.topic: how-to
6+
#customer intent: As a Visual Studio user, I want to control how XML is formatted and completed in the editor so that my documents are readable and follow my standards.
7+
f1_keywords:
8+
- VS.ToolsOptionsPages.Text_Editor.XML.Formatting
9+
- VS.ToolsOptionsPages.Text_Editor.XML.Miscellaneous
10+
ms.custom: "ide-ref"
11+
author: maddymontaquila
12+
ms.author: maleger
13+
manager: mijacobs
14+
ms.subservice: general-ide
15+
---
16+
# Configure formatting in the XML editor
17+
18+
You can control how XML elements, attributes, and other content are formatted and completed in Visual Studio. This article shows you how to configure formatting and miscellaneous options for XML editing, so your documents are readable and follow your standards.
19+
20+
## Prerequisites
21+
22+
- Visual Studio installed
23+
- An XML file or project
24+
25+
## Configure XML formatting options
26+
27+
Use the **Formatting** options page to specify how elements and attributes are formatted in your XML documents.
28+
29+
1. In Visual Studio, go to **Tools** > **Options**.
30+
2. Expand **Text Editor** > **XML**.
31+
3. Select **Formatting**.
32+
4. Choose your preferred formatting options:
33+
- **Preserve manual attribute formatting**: Do not reformat attributes. This setting is the default.
34+
> [!NOTE]
35+
> If the attributes are on multiple lines, the editor indents each line of attributes to match the indentation of the parent element.
36+
- **Align attributes each on a separate line**: Align the second and subsequent attributes vertically to match the indentation of the first attribute. Example:
37+
```xml
38+
<item id = "123-A"
39+
name = "hammer"
40+
price = "9.95">
41+
</item>
42+
```
43+
- **Auto Reformat**:
44+
- **On paste from clipboard**: Reformat XML text pasted from the clipboard.
45+
- **On completion of end tag**: Reformat the element when the end tag is completed.
46+
- **Mixed Content**:
47+
- **Format mixed content by default**: Attempt to reformat mixed content, except when the content is found in an `xml:space="preserve"` scope. This setting is the default.
48+
If an element contains a mix of text and markup, the contents are considered to be mixed content. Example:
49+
```xml
50+
<dir>c:\data\AlphaProject\
51+
<file readOnly="false">test1.txt</file>
52+
<file readOnly="false">test2.txt</file>
53+
</dir>
54+
```
55+
56+
## Configure miscellaneous XML options
57+
58+
Use the **Miscellaneous** options page to change the autocompletion and schema settings for the XML Editor.
59+
60+
1. In **Tools** > **Options**, expand **Text Editor** > **XML**.
61+
2. Select **Miscellaneous**.
62+
3. Adjust the following options as needed:
63+
- **Auto Insert**:
64+
- **Close tags**: The text editor adds close tags when authoring XML elements. If an element start tag is selected, the editor inserts the matching close tag, including a matching namespace prefix. This check box is selected by default.
65+
- **Attribute quotes**: When authoring XML attributes, the editor inserts the `="` and `"` characters and positions the caret (**^**) inside the quotation marks. This check box is selected by default.
66+
- **Namespace declarations**: The editor automatically inserts namespace declarations wherever they are needed. This check box is selected by default.
67+
- **Other markup (Comments, CDATA)**: Comments, CDATA, DOCTYPE, processing instructions, and other markup is autocompleted. This check box is selected by default.
68+
- **Network**:
69+
- **Automatically download DTDs and schemas**: Schemas and document type definitions (DTDs) are automatically downloaded from HTTP locations. This feature uses System.Net with autoproxy server detection enabled. This check box is selected by default.
70+
- **Outlining**:
71+
- **Enter outlining mode when files open**: Turns on the outlining feature when a file is opened. This check box is selected by default.
72+
- **Caching**:
73+
- **Schemas**: Specifies the location of the schema cache. The **Browse** button opens the current schema cache location in a new window. The default location is *%VsInstallDir%\xml\Schemas*.
74+
75+
## Next steps
76+
77+
- [XML tools in Visual Studio](../xml-tools/xml-tools-in-visual-studio.md)

docs/xml-tools/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
href: how-to-execute-an-xslt-transformation-from-the-xml-editor.md
3737
- name: Edit XML files
3838
href: how-to-edit-xml-files.md
39+
- name: Configure XML editor options
40+
href: options-text-editor-xml-formatting.md
3941
- name: XSLT walkthroughs
4042
items:
4143
- name: XSLT IntelliSense

0 commit comments

Comments
 (0)