google-java-format eclipse plugin ignoring formatter:off comments - Stack Overflow
The plugin adds a google-java-format formatter implementation that can be configured in Window > Preferences > Java > Code Style > Formatter > Formatter Implementation
java - Using Google code formatter in Eclipse with GWT - Stack Overflow
The google-java-formatter eclipse plugin doesn't change the format of my code
Hi y'all,
My team would like to standardise code formatting and enforce it in CI. We've tried google-java-formatter but it doesn't look nearly as good as inteliJ's default settings.
Ideally, we'd like to export inteliJs defaults (to have the benefits of built in formatter) and use something that would enforce it on CI build. Has anyone done it? What are your pipelines like? Any tips and tricks?
Could you get the xml profile in your mentioned plugin? If yes, make sure you have installed Java extension first, VSCode can use a specified Eclipse xml profile as it's formatter profile.
You can check the setting java.format.settings.url. When it's specified, the given formatter profile will be used in VSCode Java formatting.
Another way to use it is to trigger command Java: Open Java formatter settings, and it will help you generate a default formatter profile, you can change the content to what you want.
To directly set "Google Java Style" as "Java's format" on VSCode, please:
1.Install "Extension Pack for Java".
e.g: "Extension Pack for Java v0.9.1" + "Language Support for Java(TM) by Red Hat v0.64.1" for "Java1.8".
Making sure COMPILING, RUNNING and DEBUGGING are successful before "Next Step"!
2.Set the default formatter of Java into "RedHat".
2.1Using hotKeyMap to open the Settings of VSCode, e.g: Ctrl/Cmd + ,
( or Click the logo of VSCode "Code" button and choose "Preference" menu and then click "Setting")
2.2Type "javahome" in the "Search settings" space, then click "Edit in settings.json",
2.3Adding the below code into your "settings.json",
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml",
"java.format.settings.profile": "GoogleStyle",
"java.format.settings.imports.onDemand": false,
"java.format.settings.imports.regexp": "^[a-z.]*",
"[java]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "redhat.java",
"editor.tabSize": 2
}
2.4Then restart the "VSCode", Using shift + alt/option + f to automatic "Java's format" into "Google Java Style".
END!