Vscode-java: vscode-extension: Provide an action to open the formatter settings file

Created on 15 Aug 2016  Â·  17Comments  Â·  Source: redhat-developer/vscode-java

_From @egamma on July 11, 2016 8:20_

_Copied from original issue: gorkem/java-language-server#42_

enhancement

Most helpful comment

Trying to use the given workaround, how do you tell vscode to pick the formatting rules from .settings/org.eclipse.jdt.core.prefs

Just including the file in the project did not work

All 17 comments

I wanted to open an enhancement-request to provide a configuration surface for the formatter. Currently I use eclipse, and I would like to move over to vs code. But I do need a way to format the code according to a formatting policy.

Is this ticket addressing the same problem?

@houman-babai Yes, this is a request to use and edit eclipse formatting policies

Thanks @gorkem. This is a great tool, but unfortunately I cannot use it without the formatter. Over the next few month I'll see if I can learn to contribute to the project :-) In the meantime i would be grateful to know if there are any workarounds...

I would love to see it in future releases too!

Yes. please have this feature.

I'd vote for that too!
@gorkem any hints where one could find the configuration for formating-rule, might find some time to contribute…

This is very annoying. We have a specialized eclipse formatting settings but when using visual code I muck that up and there is no documented way to change it. Is there any workaround?

FWIW there is a maven plugin which uses the Eclipse formatter and can use any provided formatting configuration. A native solution would be better of course.

What is teh status of the issue?

It is the only thing preventing me from using this instead of eclipse proper.

Any news on this? I think this is really important.

Even a property like "java.formater.file" in vscode to point to my global company rules would really help. I don't want to copy the file in all of our projects by hand...

Sorry guys, there's been no new development in that area yet. As a workaround for your formatting options, please read https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings

Trying to use the given workaround, how do you tell vscode to pick the formatting rules from .settings/org.eclipse.jdt.core.prefs

Just including the file in the project did not work

Yes moving the file to the .settings folder does not seem to work

I can recommend the gradle/maven plugin spotless as a work around (https://github.com/diffplug/spotless). Your build tool then makes sure everything is formatted. It can reformat your code automatically via the command spotlessApply. Not a replacement but makes things more tolerable and enforces a single code formatting standard.

can anyone provide a sample project where .settings/org.eclipse.jdt.core.prefs are ignored?

After copying the .settings/org.eclipse.jdt.core.prefs file you need to restart vscode for the changes to be picked. It was working for me after restart. 1.21.1 version. However now i have to copy this file to each project to get formatting to work. Is there a global location to place this file?

I would like to see this feature in the next releases. In spite of the workaround works fine, could be great declared in vscode user settings a global ./settings folder to use for each project. Also, for example, org.eclipse.jdt.ui.prefs is needed as well to sort import statements.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joewood picture joewood  Â·  3Comments

gorkem picture gorkem  Â·  4Comments

ViniciusAtaide picture ViniciusAtaide  Â·  4Comments

sfariaNG picture sfariaNG  Â·  3Comments

danielcalvogonzalez picture danielcalvogonzalez  Â·  3Comments