Skip to content

Java formatting preferences

Achal Talati edited this page Nov 28, 2023 · 1 revision

Follow the steps given below to setup the custom formatter preferences:

  1. Install NetBeans.
  2. Configure your Java formatting preferences in NetBeans:
    Menu: Tools | Options | Editor | Formatting
    In the "Language" drop-down: Choose "Java"
  3. Press "Export" button (lower left corner)
  4. Check the "Editor" and "Formatting" checkboxes.
image
  1. Export the options as a .zip file, e.g. "MyNetBeansJavaFormatting.zip"
  2. Set the jdk.format.settingsPath setting in VS Code:
    In VS Code, open the "Command Palette" (Ctrl+Shift+P)
    Type "Preferences: Open User Settings (JSON)"
    Set the following property:
    "jdk.format.settingsPath": "PATH_TO_EXPORTED_NETBEANS_FORMAT_PREFERENCES_ZIP"
  3. You might also need to make sure that "Editor: Default Formatter" is set to "null" in your VS Code Settings (Ctrl+,).

Your custom Java formatting preferences should now be honoured by the "Java Platform Support" extension in VS Code.

While it may not be the perfect solution, performing this task should be a one-time requirement, unless you find yourself regularly adjusting your formatter settings.

Clone this wiki locally