Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to apply .editorconfig to existing project in intellij

I have created a .editorconfig file as shown below for intellij

# editorconfig.org

root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
indent_style = space
indent_size = 4

[*.js]
indent_size = 4

[{package.json}]
indent_style = space
indent_size = 4

How do i apply this code style to all the files in one go? Right now I will open a file and press Ctrl +Alt +l which will do the job for that file, but is there a way to apply this as the config for all the application in intellij14 ?

like image 889
dhana lakshmi Avatar asked Jan 07 '17 06:01

dhana lakshmi


People also ask

Where is .EditorConfig IntelliJ?

To use EditorConfig, make sure the EditorConfig plugin is enabled in the settings. Press Ctrl+Alt+S to open the IDE settings and select Plugins. Click the Installed tab. In the search field, type EditorConfig.

How do I import code style into IntelliJ?

Import a scheme 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.


2 Answers

just enable it... ;)

(unfortunately the setting is off by default)

Settings > Editor > Code Style

checkbox Enable EditorConfig support

enter image description here

like image 198
Michal Miky Jankovský Avatar answered Oct 28 '22 06:10

Michal Miky Jankovský


Make sure to follow the steps in Michal's answer first. If you want to retroactively apply this editorconfig to your existing files, do the following:

  • I recommend committing all your files to git so you you can reset to that commit if things did not go as planned.
  • Make sure you have a .editorconfig you are happy with.
  • In the 1:Project sidepane, right click on the folder you want to apply the .editorconfig to (e.g. the root folder of your project)
  • Choose Reformat Code, which has the default shortcut ctrlaltL.
  • Select "Include subdirectories". None of the other options are required. Then click "Run".

Your files now follow your .editorconfig file configuration.

Right-click dropdown when clicking on a folder, with Reformat Code selected Reformat Code dialog with only "Include subdirectories" checked

like image 21
Sumurai8 Avatar answered Oct 28 '22 04:10

Sumurai8