Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import .XML code style into IntelliJ Idea 15

I want to use a specific code style in my editor defined in an XML file, which looks something like this:

<code_scheme name="CustomStyleName">
<option name="JAVA_INDENT_OPTIONS">
<value>
...

How is it possible to import this style into IntelliJ Idea. When I go to Preferences->Editor->Code Style->Manage it is only possible to import an Eclipse XML Profile.

screenshot of the import dialog

like image 271
b3000 Avatar asked Jan 22 '16 15:01

b3000


People also ask

How do I add code style XML in IntelliJ?

Out of the box, IntelliJ IDEA allows you to import settings in the IntelliJ IDEA code style XML or Eclipse XML Profile format. Press Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. and select Import Scheme. Then select the necessary format.

How do I beautify XML in IntelliJ?

Either open your file in the editor and press Ctrl+Alt+Shift+L or in the Project tool window, right-click the file and select Reformat Code.


2 Answers

If your XML is previously exported Intellij you can simply do:

File > Import Settings > select your xml

If its custom defined, one you can try copying your xml to intellij config directory:

config/codestyles

Assuming your xml is in format intellij can understand, it will then show up in

Code Styles > Manage

If your XML is in different format, try to match tags with one of pre-defined styles(also XML)

like image 140
hitz Avatar answered Sep 17 '22 14:09

hitz


For users coming here for the same issue but recent IntelliJ version (like 20), it is a bit different now. Once you've exported your formatter in XML, then follow these steps:

  1. Go to Preferences
  2. Select Editor
  3. Sele Code Style
  4. Select the language of your choice (eg Java)
  5. Go to Scheme at the top, click on the setting button by the side
  6. Select the option to import scheme, choose your formatter type and select the xml file. Then save and apply.

enter image description here

If you see error "IntelliJ IDEA code style XML import failed with error message: null", check to ensure your XML file has the file definition <?xml version="1.0" encoding="UTF-8"?> at the top.

NOTE: This is for MacBook. I believe the difference won't be much in other platforms.

like image 30
Obinna Nnenanya Avatar answered Sep 16 '22 14:09

Obinna Nnenanya