简体   繁体   English

需要在 Visual Studio Code 中导入 Eclipse Java Formatter 配置文件

[英]Need to import Eclipse Java Formatter profile in Visual Studio Code

I am looking for solution for importing Eclipse Java Formatter Profile in Visual Studio Code.我正在寻找在 Visual Studio Code 中导入 Eclipse Java Formatter Profile 的解决方案。 In order to go with coding complaince.为了配合编码抱怨。 For example in IntelliJ and Eclipse for Java we do this way:例如在 IntelliJ 和 Eclipse for Java 中,我们这样做:

IntelliJ智能

  1. Download the config (attached)下载配置(附件)
  2. In the Intellij settings (Ctrl+Alt+S), go to Code Style在 Intellij 设置 (Ctrl+Alt+S) 中,转到代码样式
  3. Next to Scheme, click Manage and then Import...在 Scheme 旁边,单击管理,然后单击导入...
  4. Select 'Eclipse XML Profile' and browse to the downloaded config file.选择“Eclipse XML Profile”并浏览到下载的配置文件。

Now, every time Intellij uses its auto-formatting features, it will conform to the standards in the config file.现在,每次 Intellij 使用其自动格式化功能时,它都会符合配置文件中的标准。 This can be done quickly with the shortcut Ctrl + Alt + L .这可以通过快捷键Ctrl + Alt + L快速完成。

Eclipse日食

  1. Download the config (attached)下载配置(附件)
  2. Navigate to Window->Preferences导航到窗口->首选项
  3. Navigate to Java->Code Style->Formatter导航到 Java-> 代码样式-> 格式化程序
  4. Click on Import and navigate to the downloaded config file单击导入并导航到下载的配置文件
  5. Click Apply and Ok单击应用和确定

Now, every time Eclipse uses its auto-formatting features, it will conform to the standards in the config file.现在,每次 Eclipse 使用其自动格式化功能时,它都会符合配置文件中的标准。 This can be done quickly with the shortcut Ctrl + Shift + F .这可以通过快捷键Ctrl + Shift + F快速完成。

Note: This profile might not work while formatting xml files.注意:此配置文件在格式化 xml 文件时可能不起作用。 So go to Preferences -> XML -> Editor所以去 Preferences -> XML -> Editor

I need to know the same alternative for Visual Studio Code .我需要知道Visual Studio Code相同替代方案 Please share any pointers !请分享任何指针!

Visual Studio Code视觉工作室代码

You can use Eclipse Java Formatter Profile in VS Code like this:您可以像这样在 VS Code 中使用 Eclipse Java Formatter Profile:

  1. Install the extensionLanguage Support for Java(TM) by Red Hat .安装Red Hat 对 Java(TM)的扩展语言支持
  2. File → Preferences → Settings → java.format.settings.url : Set URL (or local file path) pointing to Eclipse Formatter Profile file.文件 → 首选项 → 设置 → java.format.settings.url :设置指向 Eclipse 格式化程序配置文件的 URL(或本地文件路径)。

See this wiki page for more information.有关更多信息,请参阅此wiki 页面

PS Also take a look to at EditorConfig which has native or plugin support for multiple IDEs / editors. PS 另请查看EditorConfig ,它为多个 IDE/编辑器提供本机或插件支持

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

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