简体   繁体   English

从intellij-idea导入代码样式格式设置到eclipse

[英]Importing code style formatting settings into eclipse from intellij-idea

I've recently implemented the maven Check style plugging into my project and have changed all of the formater Settings in intellij (Which I use) to conform to this style guide (which they now do).我最近在我的项目中实现了 maven Check 样式,并更改了 intellij(我使用的)中的所有格式化程序设置以符合此样式指南(他们现在这样做)。

However I need to produce a settings .xml file for eclipse, so that my colleagues can automatically format there code so that it also conforms to this style guide.但是,我需要为 Eclipse 生成一个设置 .xml 文件,以便我的同事可以自动格式化那里的代码,使其也符合此样式指南。

The problem I am finding is that I cannot see a way of exporting the settings from intellij and importing them into eclipse.我发现的问题是我看不到从 intellij 导出设置并将它们导入 eclipse 的方法。 and I cannot manually configure eclipse to conform with the nuances of the new style guide (Continuation indentation being the main problem).而且我无法手动配置 eclipse 以符合新样式指南的细微差别(继续缩进是主要问题)。

Any help or Ideas would be fantastic.任何帮助或想法都会很棒。 :) :)

I couldn't find a ready plugin for that in 2018. So here is a side by side code style configuration from UI perspective of Intellij IDEA 2017.3 and Eclipse OXYGEN.3 March 2018. If both configured this way the code will be formatted close enough, so for example github will show you code differences so that it make sense.我在 2018 年找不到一个现成的插件。所以这里是从 Intellij IDEA 2017.3 和 Eclipse OXYGEN.3 March 2018 的 UI 角度来看的并排代码样式配置。如果都以这种方式配置,代码的格式将足够接近,因此例如 github 将向您展示代码差异,以便它有意义。

For our project we configured one XML for each IDE so they more or less match:对于我们的项目,我们为每个 IDE 配置了一个 XML,以便它们或多或少地匹配:

  • IntelliJ Config File is default of IDEA 2017.3 so not much to define in XML - enter link description here IntelliJ 配置文件是 IDEA 2017.3 的默认值,所以在 XML 中没有太多定义 - 在此处输入链接描述
  • Eclipse Config is modified a bit from the default to match IntelliJ - link Eclipse Config 从默认设置中稍作修改以匹配 IntelliJ - 链接
  • Here is also a PDF file to show all the options set in both IDEs side by side - link这也是一个 PDF 文件,用于并排显示在两个 IDE 中设置的所有选项 - 链接

There is also a project to solve this problem across more IDEs( Answer ) : EditorConfig还有一个项目可以跨更多 IDE 解决这个问题(答案EditorConfig

You can export settings in Intellij by clicking on File > Export Settings but they will be in .jar format.您可以通过单击文件 > 导出设置来导出 Intellij 中的设置,但它们将采用 .jar 格式。

According to this thread there is no easy way of importing settings.jar into eclipse.根据这个线程,没有简单的方法可以将 settings.jar 导入到 eclipse 中。

Eclipse - import code format settings Eclipse - 导入代码格式设置

I hope this helps :)我希望这会有所帮助:)

There is a EditorConfig - independent format for editors/IDEs code style configuration.编辑器/IDE 代码样式配置有一个独立的EditorConfig格式。 There are EditorConfig plugins for most popular editors(see full list here ).有适用于大多数流行编辑器的 EditorConfig 插件(请参阅此处的完整列表)。

You can see examples for IntelliJ IDEA( tutorial ) and Eclipse( plugin page ).您可以查看 IntelliJ IDEA( 教程)和 Eclipse(插件页面)的示例。

The exact data from JetBrains is here. JetBrains 的确切数据在这里。 Check out the Link查看链接

Hit like if this helps.如果这有帮助,请点击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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