简体   繁体   中英

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 shot right know i will open a file and press Ctrl + Alt + l which will do the job is there a way to apply this as the config for all the application in intellij14

just enable it... ;)

(unfortunately the setting is off by default)

Settings > Editor > Code Style

checkbox Enable EditorConfig support

在此处输入图片说明

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 (eg the root folder of your project)
  • Choose Reformat Code , which has the default shortcut ctrl alt L .
  • Select "Include subdirectories". None of the other options are required. Then click "Run".

Your files now follow your .editorconfig file configuration.

单击文件夹时右键单击下拉列表,并选择重新格式化代码 仅选中“包含子目录”的重新格式化代码对话框

If you added the file after project initialization.

You need to add the file .editorconfig on the root of the project.

Once happy with you file configuration right click and select synchronize '.editorconfig'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM