SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
MIT License
436 stars 83 forks source link

Can't highlight multiple lines and ?si issue #60

Closed yogurt-island-331 closed 9 years ago

yogurt-island-331 commented 9 years ago

Hi there, first thanks for creating this tool, it's super useful. I am trying to write a syntax package for myself, here is the tmLanguage file: https://gist.github.com/a01379aa77c176df409b.git, but for some reason, I can't do highlighting on multiple lines. I am having issue with the section has the comment "kz part on select * from xxx"

If you use this package on this line: SELECT * FROM all_KZ LIMIT 10;

You will see that the table name after "FROM" is not highlighted as I wanted as "entity.name.function.pgsql," is this an issue for the package or am I doing something wrong? I tried to use "\n","\r\n" to replace "\s", but still didn't work...then I tried to change:

(?i:^\s*(select)\s+(\*)\s+(from)\s+([a-zA-Z+\_]+)\s+(limit)\s+(\d+))

to

(?si:^\s*(select)\s+(\*)\s+(from)\s+([a-zA-Z+\_]+)\s+(limit)\s+(\d+))

so that I can use "." to represent new line symbol, but then Sublime keep saying there is an error and won't let me do it...

Thank you so much!

FichteFoll commented 9 years ago

It is not possible to capture text beyond the closing newline (\n) of a line. I assume this is because the regular expression match is only applied to that part of the text, optionally starting from a newline, spanning the line's text and then optionally ending with a newline.

What you can do can be achieved by splitting these matches individually (one for select, one for from and one for limit) or with the new .sublime-syntax format that has been added to the dev builds recently: http://www.sublimetext.com/docs/3/syntax.html

yogurt-island-331 commented 9 years ago

Thanks! How can I use the new .sublime-syntax? On the doc it says "Regexes are only ever run against a single line of text at a time."

yogurt-island-331 commented 9 years ago

sbulime Out of curiosity, is it possible to use the begin and end capture to do multiple lines?

FichteFoll commented 9 years ago

Yes, begin-end-matches match independently of line, but this will only work for the content. The begin and end patterns themselves are only matched against one line.

yogurt-island-331 commented 9 years ago

I see...thank you so much! Do you know where I can find more info on how to write my own code for

.sublime-syntax 

files?

FichteFoll commented 9 years ago

No, http://www.sublimetext.com/docs/3/syntax.html is the only resource available currently. You should look at the examples if you haven't already.