I just switched from Eclipse to IntelliJ and noticed that when I use "Reformat code" feature it doesn't work like it is in Eclipse, i.e. it uses different number of spaces in my xml files. Is there a way to configure it?
Yes, you can change it in the XML code style settings:
Related
I want to set code style for the project so that all the developers of the project format the code the same way. All of the team uses IntelliJ. When I add my style in the file
/myproject/.idea/codeStyleSettings.xml
the IDE creates the file
/myproject/.idea/codeStyles/codeStyleConfig.xml
with the contents
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
Will the default settings override my code style settings? Should I use the same component name in my settings file to override the default one?
In addition to those, I see a codeStyle.xml file in the root directory of some well-known java libraries such as https://github.com/qos-ch/slf4j , is it for another IDE or does that also have an impact on formatting in IntelliJ?
By the way, I think generally code style config is confusing if not mess, there is also IDE level global settings and I think/hope it will be applied when there are no rules for a specific option, right?
Intellij IDEA 2017.3 has got new project code style settings format. Now all code style settings are located under <PROJECT_ROOT>/.idea/codeStyles directory with the ultimate intention to support multiple project code styles linked to different scopes. New code style settings format is also cleaner and contains all code style settings properly grouped per language. Some old legacy Java, HTML settings previously stored without any language tag are moved to "JavaCodeStyleSettings", "HTMLCodeStyleSettings" etc. respectively.
The old .idea/codeStyleSettings.xml is imported into two new files: .idea/codeStyles/codeStyleConfig.xml containing a link to preferred project code style and .idea/codeStyles/Project.xml with code style settings for different languages. The latter is optional and created only if there are non-default settings. If .idea directory is under version control, both files can be added to VCS too. The old codeStyleSettings.xml is kept for backwards compatibility.
Original answer (now obsolete):
.idea/codeStyleSettings.xml stores the project specific code style that is for sharing with the project so that all the team members have the same code style applied automatically for this specific project. Check this answer for details.
.idea/codeStyles/codeStyleConfig.xml is used to override the default project code style.
By default it contains <option name="USE_PER_PROJECT_SETTINGS" value="true" /> so that project specific configuration from .idea/codeStyleSettings.xml is used. If you switch your code style settings to use a scheme stored in the IDE instead of the project scheme, this file will store your choice.
IntelliJ IDEA also has support for .editorconfig which will have the priority and override IDE and project scheme by default. Check the documentation for more details.
codeStyle.xml in the project root is for Eclipse IDE and is not used by IntelliJ IDEA. It can be probably used by IntelliJ IDEA as well, if you have Eclipse Code Formatter plug-in installed and configured accordingly.
I have Jenkinsfile it's written in Groovy, but file name doesn't have approprite extension: .groovy. How can I tell IDEA to check groovy syntax of this file?
Update:
Also I interested in the same question about GoLand IDE
From the project sidebar, right-click the file and choose "Associate with File Type". Then just select Groovy from the menu, and you're all set.
GoLand does not support Groovy so this will not be possible there.
If you add following header comment in the beginning of your Jenkinsfile:
#!groovy
IntelliJ IDEA will automatically recognize this file as a Groovy source file. It should work for other editors and IDEs as well.
A little intro:
I work on a project with legacy codebase witch uses internal xml based descriptors with specific file extensions (about may be 10 extensions).
Let it be *.desc, *.check etc.
To have code highlighting for such a files I can configure Idea to consider these types of files as XML.
It's available through:
Preferences / Editor / File types
And then add all custom extensions to 'Recognized file types': 'XML'
Our project uses gradle as build tool
and my question is:
Is it possible to make same configuration via dsl of gadle 'idea' plugin?
The short answer is: No.
One could create a custom Gradle task that will modify IDE file type preferences XML file in the config directory. While it's possible to run such task automatically on the project refresh in IntelliJ IDEA, it will most likely not work since you can't modify IDE configuration when IDE is running (the changes will be reverted). So, you will have to run it from the command line, outside of IntelliJ IDEA when IDE is not running.
It's probably not what you want, but if documented, can be used by the team as the manual step to make this configuration change easier.
Using gradle idea is not recommended anyway.
A better way might be to provide your own IDE plug-in that will associate these file extensions with XML file type and instruct the team to install this plug-in.
I'm using IntelliJ 2016.2 and have imported our project eclipse formatting settings, set up with Eclipse Formatting. Is it possible to create an ignore filter that IntelliJ will use to decide which files should be auto formatted when saving? I'd like save actions to be disabled for *.py files.
IntelliJ does not format files on save, a third-party plugin does that, check its config.
I am creating a few Apache FOP documents using velocity and XSLT templates and I find it very difficult to work with Intellij IDE because it doesn't give me hints of the allowed attributes for a node and marks as "error" all the nodes. Is there any plug-in I can use that solves this problem?
I have tried with the only one I have found online:
https://plugins.jetbrains.com/plugin/7736?pr=idea
But it doesn't seem to do much.
Any ideas?
It seems, that you don't have properly set XML schema for namespace http://www.w3.org/1999/XSL/Format in the IDE. I had the
same problem when I asked Idea to download missing schemas.
Instead of downloading, the IntelliJ Idea created the empty one.
This helped me:
Download XML schema for XSL:FO files (from Apache/FOP or RenderX).
In the IntelliJ Idea associate URI http://www.w3.org/1999/XSL/Format to the downloaded file (Preferences -> Languages & Frameworks -> Schemas & DTDs).
Links:
XML Schemas for XSL:FO
IntelliJ Idea Help