Skip to content

java formatter: unable to wrap/break long Strings #3985

Open
@reuschling

Description

@reuschling

I come from Intellij idea and I'm used to break long lines with the formatter. I managed to export/import most of the settings, but I can not manage it that vscode breaks long String lines, splitting the Strings with "firstPart" + "secondPart".

These are my related settings in the codeFormatterSettings.json:

<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="180"/>
<setting id="org.eclipse.jdt.core.formatter.formatter_wrap_long_strings" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_strings" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>

Please ask if I should upload the whole file.

This is an example line of code:

String strSystemPrompt =
                "You are a system that generates a concise and informative answer in less than 100 words for the given question, which is marked with QUESTION. Use the given search results marked with SEARCH RESULT as only knowledge base. Answer questions in the language of the question, i.e. german questions in german and only english questions in english.";

This is the expected output:

String strSystemPrompt =
                "You are a system that generates a concise and informative answer in less than 100 words for the given question, which is marked with QUESTION. Use the given search" + 
                "results marked with SEARCH RESULT as only knowledge base. Answer questions in the language of the question, i.e. german questions in german and only english" + 
                "questions in english.";

Am I missing something, is it not supported, or is it a bug?

VSCode version 1.98.2
Java Language support:
Version
1.40.0
Last Updated
2025-03-06, 08:33:26

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions