Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set IntelliJ to place xml tags on separate lines when formatting xml files?

I'm using IntelliJ IDEA 12. I've used the context menu to import some pom.xml maven dependencies. However, when I view the POM file, the dependencies are not formatted nicely--they are in a single line. When I reformat the pom file (Ctrl-Alt-L) the formatting is still not fixed.

I tried looking at Project Settings > code style > XML, but I couldn't see an obvious setting that would fix this. I fiddled with "keep line breaks" and "wrap text" settings, but to no avail.

I have noticed that other XML files have the same issue--if I join them, formatting won't break them apart.

How can I get IntelliJ to intelligently break xml across multiple lines, with proper indentation?

like image 664
Kimball Robinson Avatar asked Jun 27 '14 21:06

Kimball Robinson


People also ask

How do I align lines in IntelliJ?

Open indentation settings in code style scheme Click the widget and select Configure Indents for 'Language'. In the dialog that opens, you can change settings for tabs and indents and also configure other code style settings. Click OK. Reformat the necessary part of your project to apply new indentation settings.

How do I change settings XML in IntelliJ?

If you have some custom plugins that require you to import your project from the IntelliJ IDEA model, press Ctrl+Shift+A and search for the Project from Existing Sources action. In the dialog that opens, select the pom. xml file of the project you want to open. Click OK.

How do I use XML in IntelliJ?

XML. XML. . IntelliJ IDEA brings powerful support for XML that includes structure validation, formatting ( Ctrl+Alt+L) and indentation ( Ctrl+Alt+I according to the XML code style, importing unbound namespaces, viewing code structure, unwrapping and removing tags ( Ctrl+Shift+Delete ), generating DTD files and schemas from instance documents, ...

How do I change the right side margin in IntelliJ?

If the checkbox is cleared, IntelliJ IDEA deletes the tab characters and spaces on empty lines. Use these settings to specify a margin space required on the right side of an element. If you select Default option then a value of the right margin from the global settings will be used.

How do I add honor line breaks in IntelliJ IDEA?

Select this checkbox to have IntelliJ IDEA honor line breaks in attributes (for example, lengthy descriptions) when reviewing XML files in the editor. In this text box, specify the minimum number of sequential blank lines to be retained after reformatting. Use this drop-down list to determine how attribute lines should be wrapped.

Why does IntelliJ IDEA use spaces instead of tabs?

If the checkbox is cleared, IntelliJ IDEA uses spaces instead of tabs. An indentation consists of two parts. One part results from nesting code blocks, and the other part is determined by alignment.


1 Answers

Uncheck the option "keep white spaces" in the settings.

In IDEA 12, File > Settings > Code Style (left menu panel) > XML (left menu panel) > Other (tab) > Keep White Spaces (checkbox)

like image 137
Kimball Robinson Avatar answered Oct 03 '22 07:10

Kimball Robinson