Sublime Forum

[Solved] Sublime Syntax

#1

Hello,

I am trying to create syntax higlighting accoridng to the instrucitons that are given in the documentation and it works wonderful.
The only issue that I have is matching of multiline comments like in C#.

- match: (/\*.*?\*/\n?|/\*\n|\*/\n)
  scope: comment.line

This is only matching single lines but not the complete blockquoute. Anybody able to help me out?

Thanks!

0 Likes

#2

You cannot make a regex to match multiline. I don’t exactly test the following code.

- match: /\*
  meta_scope: comment.line
  push:
    - match: \*/
      pop: true

This is not exactly mentioned but you should know how to do it after reading Selected Examples section in the doc.

1 Like

#3

Thank you for your feedback, but even with you help and the documentation I am not getting it to work.

This is as far as I got:

- match: /\*(.*)
  scope: comment.line
  push:
    - match: (.*)\*/
      scope: comment.line
      pop: true

Care to help me again?

0 Likes

#4

I just test my code.

%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
  - myTest
scope: source.example
contexts:
  main:
    - match: /\*
      meta_scope: comment.line
      push:
        - match: \*/
          pop: true

It works correctly. I am not sure what the problem that you exactly encountered is. Maybe paste full codes?

0 Likes

#5

ooh, I never knew ScopeHunter could show it like that - just edited my settings and now it’s much nicer to work with! :smiley: thanks @jfcherng :wink:

1 Like

#6

What package are you using to show the scope? Quite new to working in depth with ST.

The issue that I am having is, that everything seems to match (using invalid.illegal scope as it is changing background in my current theme):

0 Likes

#7

It’s ScopeHunter or you may use ctrl+alt+shift+p as a ST built-in command as well. There are some settings for ScopeHunter that you can adjust if you interest.


I personally use ScopeHunter to replace the built-in scope-finding command.

{ "keys": ["ctrl+alt+shift+p"], "command": "get_selection_scope" },
0 Likes

#8

Ah, you are right. Something went wrong in my codes. I used meta_scope in a wrong way.

%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
  - myTest
scope: source.example
contexts:
  main:
    - match: /\*
      push:
        - meta_scope: comment.line
        - match: \*/
          pop: true

0 Likes

#9

Thank you, that did the job! :slightly_smiling:

0 Likes

#10

Although that should obviously be a comment.block scope.

1 Like

#11

Sorry about that, not a syntax master :stuck_out_tongue_closed_eyes:

1 Like

#12

Thank you very much jfcherng, you saved my day,

this one has added by me

- match: /\*
  scope: punctuation.definition.comment.source.gcf
  push:
    - meta_scope: comment.block.source.gcf
    - match: \*/\n?
      scope: punctuation.definition.comment.source.gcf
      pop: true
0 Likes