Pascal multi line string highlight
-
Hello,
Delphi (Object Pascal) supports multi-line strings in its recent versions.
It would be nice to have it visualized as string in Notepad++Three single quote characters starts multi-line. Three single quote characters finish multi-line.
Starting cannot have any string after quote characters
Finishing cannot have any string before quote charactersSample multi-line
LColorQuery.SQL.Text := ''' select name from colors where autoinc=:id ''';
What is displayed in Notepad++ is like below now
How regular strings are displayed is like below (“picture path” is string)
Thank you for your consideration.
Regards,
ErtanP.S. Forum highlighter correctly displayed multi-line in different color.
-
@Ertan-Küçükoglu said in Pascal multi line string highlight:
It would be nice to have it visualized as string in Notepad++
Notepad++ uses a library called “Lexilla” to handle deciding what characters in a document to syntax highlight. When I use their testbed “SciTE” editor, it is showing that it’s treating the line ending with
'''
as an “unterminated string”. But it apparently doesn’t know that Delphi recently added multi-line strings with the triple-quote syntax.The Lexilla project has ome reported issues about Pascal and Delphi – you can look through those, and see if any mention the multi-line strings. If not, you might want to request that they add it. Once they add it, and Notepad++ updates its Lexilla library, then Notepad++ could add that new styleID to the Style Configurator options for Pascal. But until they add the support, there’s nothing Notepad++ can do about the official lexing of the language.
However, as a workaround, there is a plugin called “EnhanceAnyLexer”, which allows you to add regex-based foreground colors. Doing multi-line stuff with a regex is risky if there’s a mismatched triple-quote somewhere, but once you install EnhanceAnyLexer, open your Delphi/Pascal file, use Plugins > EnhanceAnyLexer > Enhance current language, which will open up a
[pascal]
section in theEnhanceAnyLexerConfig.ini
. Set it to the following[pascal] ; Everything between pairs of triple-ticks is colored cyan 0xCCCC00 = (?s)'''.*?''' ;excluded_styles = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23
(make sure you use the
;
or#
to coment out theexcluded_styles
, otherwise it won’t color properly; you can, of course, pick any 0xBBGGRR values you want to choose your own color, as described in the comments of the INI file.)With that INI saved, it will mean that from now on, the EnhanceAnyLexer plugin will color triple-quote multi-line strings in Delphi/Pascal files. like this example:
Since some people aren’t clear when I’ve given such instructions: once you save the
EnhanceAnyLexerSettings.ini
, the EnhanceAnyLexer will always apply that regex-based coloring to Pascal/Delphi files (you don’t have to run Enhance current language every time you want to turn it on; with the plugin installed, and the ini saved, it will be automatic).