How to change max line length for formatter provided by Language Support for Java(TM) by Red Hat extension in Visual Studio Code?

Viewed 1783

I have the Language Support for Java(TM) by Red Hat extension installed in Visual Studio Code. Among other features, this extension can auto-format java code. I have it set to do this whenever I save the file.

It appears to have the max line length set to 120 characters, but I would like to set it to 80 characters. I have been searching everywhere but I can't figure out where to find the relevant setting.

Is it possible to set the formatter to a different max line length? If so, how?

1 Answers

In Settings.json, set

"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 79,

When code is over the max length, which is 80 now, it will turn to the next line:

enter image description here

After coding, right click in current .java file and choose Format Document, all code will be formatted by the wordWrap setting and the max length will be 80.

Related