Sumitiscreative
Sumitiscreative

Reputation: 757

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. In order to go with coding complaince. For example in IntelliJ and Eclipse for Java we do this way:

IntelliJ

  1. Download the config (attached)
  2. In the Intellij settings (Ctrl+Alt+S), go to Code Style
  3. Next to Scheme, click Manage and then Import...
  4. Select 'Eclipse XML Profile' and browse to the downloaded config file.

Now, every time Intellij uses its auto-formatting features, it will conform to the standards in the config file. This can be done quickly with the shortcut Ctrl+Alt+L.

Eclipse

  1. Download the config (attached)
  2. Navigate to Window->Preferences
  3. Navigate to Java->Code Style->Formatter
  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. This can be done quickly with the shortcut Ctrl+Shift+F.

Note: This profile might not work while formatting xml files. So go to Preferences -> XML -> Editor

I need to know the same alternative for Visual Studio Code. Please share any pointers !

Upvotes: 16

Views: 16163

Answers (1)

haba713
haba713

Reputation: 2687

Visual Studio Code

You can use Eclipse Java Formatter Profile in VS Code like this:

  1. Install the extension Language Support for Java(TM) by Red Hat.
  2. File → Preferences → Settings → java.format.settings.url: Set URL (or local file path) pointing to Eclipse Formatter Profile file.

See this wiki page for more information.

P.S. Also take a look at EditorConfig which has native or plugin support for multiple IDEs / editors.

Upvotes: 13

Related Questions