java 如何将所有 Intellij 代码样式导出到 .editorconfig 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35915970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to export all my Intellij code styles to a .editorconfig file?
提问by edwise
I'm trying to have a standard code style for my project, and I have found http://editorconfig.org/, that is a standard for that. I like it very much, and Intellij supports it (we use Intellij).
我正在尝试为我的项目设置标准的代码样式,我发现http://editorconfig.org/是一个标准。我非常喜欢它,Intellij 支持它(我们使用 Intellij)。
But I have read a lot and I haven′t found how I can export all my code styles of Intellij to a .editorconfig file. I only can export them to an XML that is only for Intellij.
但是我读了很多,我还没有找到如何将 Intellij 的所有代码样式导出到 .editorconfig 文件。我只能将它们导出为仅适用于 Intellij 的 XML。
Or is there any webpage where I can read ALL the editorconfig domain specific properties for Java? In the editorconfig github wikithey only have a few.
或者是否有任何网页可以让我阅读 Java 的所有 editorconfig 域特定属性?在editorconfig github wiki他们只有几个。
回答by Pytry
Go to "File->Settings->Editor->Code Style". At the bottom of the right pane there is a section for Editor Config options, which now includes an "Export" button. This will only export formatting options that are available in the Editor Config specification.
转到“文件->设置->编辑器->代码样式”。在右窗格的底部有一个编辑器配置选项部分,现在包括一个“导出”按钮。这只会导出编辑器配置规范中可用的格式选项。
To include advanced options from IDEA you will have to save IntelliJ specific files with the project.
要包含来自 IDEA 的高级选项,您必须将 IntelliJ 特定文件与项目一起保存。
If you want to do this without saving the entire ".idea" folder and "*.iml" files, you can also export the IDEA configuration to an xml file and save in a place where everyone can get to it.
如果您想在不保存整个“.idea”文件夹和“*.iml”文件的情况下执行此操作,您还可以将 IDEA 配置导出为 xml 文件并保存在每个人都可以访问的地方。
- In "File->Settings->Editor->Code Style". At the top of the right pane, there will be a "Scheme" field with an dropdown of options.
- Next to the dropdown is a cog/gear image that will expand to give some options depending on which scheme you have selected.
- The two options you need are the "Export..." option and the "Import Scheme" options which do what their names imply.
- 在“文件->设置->编辑器->代码样式”中。在右侧窗格的顶部,将有一个带有选项下拉列表的“方案”字段。
- 下拉菜单旁边是一个齿轮/齿轮图像,它将根据您选择的方案展开以提供一些选项。
- 您需要的两个选项是“Export...”选项和“Import Scheme”选项,它们的名称含义相同。
回答by Harmelodic
Don't think IntelliJ will do this for you.
不要认为 IntelliJ 会为你做这件事。
You'll probably have to Export IntelliJ's Code Styles as a "Code Style XML File" and then manually parse that to your EditorConfig file. Or find a parser on the internet.
您可能必须将 IntelliJ 的代码样式导出为“代码样式 XML 文件”,然后手动将其解析为您的 EditorConfig 文件。或者在网上找个解析器。
To export all your Code Styles from IntelliJ:
从 IntelliJ 导出所有代码样式:
- Hit "Ctrl + Alt + S".
- Editor > Code Style.
- Click the "Manage" button next to where IntelliJ states your Scheme.
- Export > Export as Code Style XML File.
- 点击“Ctrl + Alt + S”。
- 编辑器 > 代码样式。
- 单击 IntelliJ 说明您的方案旁边的“管理”按钮。
- 导出 > 导出为代码样式 XML 文件。
HTH
HTH