We talked brielfy about using \ to prevent editors from stripping whitespace from multi-line string literals.
Something else that I'd love to have is the ability to prevent the formatter from merging lines in other collections, and I thought it would be nice to use it there also.
# format the line, but keep the breaks
matrix =
(
1, 0, 0, \
0, 1, 0, \
0, 0, 1, \
)
# keep the trailing spaces
multi-line-str =
"""Some thing \
"""other line \
I feel like even without \ that it would be incorrect behaviour to strip trailing spaces from multiline strings.
That just sounds highly bug prone.
Probably would be fine for the formatter to insert the \ though
I think the problem is some editors will strip the trailing whitespace on save
Or maybe I misunderstood that previous conversation
I agree the roc formatter shouldn't do that
I think the problem is some editors will strip the trailing whitespace on save
Oh...hmm... didn't realize that
If that is the case, trailing \ makes sense as a solution
isn't # already a 1-character solution to this problem? :thinking:
I guess it could be, but current formatter does this (just tried it out)
matrix =
(
1,
0,
0, #
0,
1,
0, #
0,
0,
1, #
)
I was a passing thought, I haven't really thought hard about it. It just felt like a similar thing to the multi-line string thing.
ah interesting
I would always assume everything in the line after the multiline string starts is part of the string. Having to escape, trailing \ would be annoying for example when having a markdown string. That's probably more common than trailing spaces? And I don't know of any editor that removes trailing spaces without explicit configuration.
For collections using # makes a lot of sense to me. And its also more discoverable, if you want to annotate the lines.
And I don't know of any editor that removes trailing spaces without explicit configuration.
IIRC Zed was doing this a while ago at least, presumably because of auto-rustfmt on save (by out-of-the-box config). Ran into exactly this case when editing some test cases for the old compiler a while back, where editing anything in the file in zed would make the tests break because it stripped trailing spaces in the multi-line strings we were comparing our output to.
Last updated: Jun 16 2026 at 16:19 UTC