You now can! After a long discussion on the FPC-devel mailing list, I spent some time over the last week implementing this functionality, and have now opened an issue on the bugtracker for it which is currently awaiting review:
https://bugs.freepascal.org/view.php?id=35827If this is something that interests you, please feel free to test the patch (or directly test a build of FPC from my Github fork branch, which is linked on the tracker issue) as I'd love to get some additional real-world user feedback on this.
Edit:(A basic explanation of the feature, that I also just posted on the tracker issue)
Here's a simple example adapted from one of my tests, that I think clearly explains how the trim directive works, that I'm posting here to make it more directly accessible:
program Example;
// You must set the below modeswitch to use the feature,
// and will get an "illegal char" error at the opening
// backtick of the first multi-line string encountered if you don't.
// To be clear: multi-line strings are exclusively denoted with backticks,
// not single quotes.
{$modeswitch MultiLineStrings}
{$MultiLineStringTrimLeft 1}
// There's two leading spaces on each line
// of the multi-line string below. One will
// be removed from each line, based on what we
// just set for the trim directive.
const A = `
A
B
C
D
`;
{$MultiLineStringTrimLeft 3}
// There's four leading spaces on each line
// of the multi-line string below. Three will
// be removed from each line, based on what we
// just set for the trim directive.
const B = `
A
B
C
D
`;
begin
Write(A);
Write(B);
end.
The output of that is, thus:
A
B
C
D
A
B
C
D
since we first remove one space from where only two existed, and then remove three spaces from where four existed, leaving us with identical strings that have one leading space on each line.
Note that the default setting for MULTILINESTRINGTRIMLEFT is 0, meaning, by default no whitespace is removed.
If you set the directive to a higher number than the amount of leading whitespace present, the scanner will just stop skipping characters when it hits a non-whitespace one anyways, so you don't need to worry about mangling your strings or anything like that.
Additionally (as was an actual requirement specified for this feature by Michael van Canneyt) there exists a {$MULTILINESTRINGLINEENDING} directive, which takes one of CR, CRLF, LF, PLATFORM, or RAW as valid options. This specifies which particular line ending characters (or combination of characters in the case of CRLF) should be used at the end of each line in a multi-line string.
For anyone not aware:
CR = #13
CRLF = #13#10
LF = #10
PLATFORM means the compiler will use whichever line ending type is native to your operating system. RAW means the compiler will use the line endings exactly as present in the physical source file. RAW is the default.