In Sublime Text 3, a default syntax highlighting rule paints a SQL SELECT just fine if it's in the same line, but not if it's in the next line:

single-line sql string vs multiline sql string

After reading this question I opened the PHP package (this is a php project) and looked at the syntax rules (PHP.tmLanguage):


As far as I could tell that regex is correct, but I still tested it in regex101. It does capture the SELECT just fine there, so I don't think there is any problem with the actual regex.

Any idea how to make the syntax highlighted on multiple line SQL strings?

  • My best guess: \s isn't selecting newlines, and [\s\r\n] needs to specified. Alternatively, there's some override on newlines elsewhere. I'm not super familiar with Sublime Text, but hopefully this is a bit helpful. – Graham May 4 '18 at 2:38
  • Okay, I just installed Sublime Text and looked at the syntax highlighting for the PHP example you provided, and it highlighted the SELECT whether or not there was an indent after the opening quotation mark. I also don't know where you got the PHP.tmLanguage; I looked at the syntax in PHP.sublime-package, and don't currently have a file called PHP.tmLanguage on my computer. – Graham May 4 '18 at 22:33
  • @Graham My initial problem was not with an indent, but with a line break. Also, I asked that question on July 13th 2015, I guess quite a lot has changed in Sublime in the last 3 years. But please feel free to try with a line break, not an indent. Disclaimer: I dont use Sublime anymore – Purefan May 5 '18 at 11:32
  • Sorry, I didn't look at the asking date carefully. Whoops. I also meant line break instead of indent. – Graham May 6 '18 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.