Skip to content

Mark corresponding variable in String.formatted(..) if cursor is on %s (and vice versa) #4350

Closed

Description

@reuschling

If you have big Strings, e.g. block Strings, with some %s (or other) placeholders for variables that are then inserted with an .formatted(...) invocation, it is sometimes really hard to see

  1. where the placeholder occurs in the String, or
  2. which variable name the placeholder refers to.

For 1. a solution would be to mark the corresponding placeholder inside the String if the cursor is on a variable inside .formatted(...)

For 2. one solution would be to highlight the according variable inside the .formatted(..) invocation. An alternative would be a popup with the variable name.

Activity

  1. fbricon commented on Feb 26, 2026

    @fbricon
    Collaborator

    How about providing inlay hints instead? that would cover both cases IMHO:

        IO.println("Hello %s and welcome!".formatted(name));
    

    would render as :

        IO.println("Hello %s :name and welcome!".formatted(name));
    

    No need to hover, you know exactly which placeholder matches to what

  2. fbricon commented on Feb 26, 2026

    @fbricon
    Collaborator

    like that :-)

    Image
  3. added this to the End March 2026 milestone on Feb 26, 2026
  4. self-assigned this
    on Feb 26, 2026
  5. reuschling commented on Feb 27, 2026

    @reuschling
    Author

    This is fantastic, even better as highlighting corresponding things. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions