Search code examples
javavisual-studio-codeintellij-ideacheckstyle

Using VS Code java formatter in IntelliJ


I'm using checkstyle in my springboot project, VS code formatter that I think came from redhat is able to automatically format the import order, and code length so it doesn't violate checkstyle rules.

Thing is, I hated debugging in VSCode and prefer Intellij for debugging and other stuff.

Is there anyway I could use VSCode formatter in Intellij?


Solution

  • Since you're already using Checkstyle, you can configure IntelliJ to auto-format your code according to Checkstyle rules:

    1. Install the Checkstyle Plugin in IntelliJ.
    2. Go to Preferences > Tools > Checkstyle and import your Checkstyle rules XML.
    3. Enable Checkstyle as a code formatter in Preferences > Editor > Code Style > Java.

    Pros: Ensures consistency with Checkstyle.
    Cons: May not 100% match VS Code, but it prevents Checkstyle violations.