Sublime Forum

Multi line comment with one char

#1

Hello,
I would like to add new character, that would indicate multi line comment with
char for beginning a comment: ´
char for ending a comment: `
such as : ´this is a comment`.
Is it possible to start multi line comment with one character or it has to be two as in case of /* ?
Would it be better if char would be the same for start and end? Thank you

0 Likes

#2

Isn’t that purely depends on the language specification?

0 Likes

#3

I am not changing any language. Thank you for your question.

0 Likes

#4

I tried to add next to

Packages\Text.sublime-package\Plain text.sublime-syntax

but it does not work. Any idea why?

  • match: /\´
    scope: punctuation.definition.comment.begin.sql
    push: inside-comment-block
    inside-comment-block:
  • meta_include_prototype: false
  • meta_scope: comment.block.sql
  • match: `
    scope: punctuation.definition.comment.end.sql
    pop: true
  • match: ^\s*(´)(?!`)
    captures:
    1: punctuation.definition.comment.sql
    regexps:
  • match: /(?=\S.*`)
    scope: punctuation.definition.string.begin.sql
    push:
    • meta_include_prototype: false
    • meta_scope: string.regexp.sql
    • match: `
      scope: punctuation.definition.string.end.sql
      pop: true
    • include: string-interpolation
    • match: \`
      scope: constant.character.escape.slash.sql
0 Likes

#5

What you are actually trying to do is still not clear imho.

I see Plain text.sublime-syntax but at the same time I see sql. And, partial content maybe belongs to Packages\Text.sublime-package\Plain text.sublime-syntax.

What’s your targeted syntax file? You want custom comment grammar for plaintext files?

0 Likes

#6

Yes. That would be great.

0 Likes

#7
%YAML 1.2
---
# See http://www.sublimetext.com/docs/syntax.html
name: Plain Text
scope: text.plain
contexts:
  main:
    - include: comments

  comments:
    - match: '´'
      scope: punctuation.definition.comment.begin.plain
      push:
        - meta_scope: comment.block.plain
        - match: '`'
          scope: punctuation.definition.comment.end.plain
          pop: true

should work.

However, the one ST used by default is the .tmLanguage hardcoded. So, it should be written in .tmLanguage to override the builtin syntax.

1 Like

#8

Plain text.tmLanguage

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
  <dict>
    <key>fileTypes</key>
    <array>
      <string>txt</string>
    </array>
    <key>name</key>
    <string>Plain Text</string>
    <key>patterns</key>
    <array>
      <dict>
        <key>name</key>
        <string>comment.block.plain</string>
        <key>begin</key>
        <string>´</string>
        <key>beginCaptures</key>
        <dict>
            <key>0</key>
            <dict>
                <key>name</key>
                <string>punctuation.definition.comment.begin.plain</string>
            </dict>
        </dict>
        <key>end</key>
        <string>`</string>
        <key>endCaptures</key>
        <dict>
            <key>0</key>
            <dict>
                <key>name</key>
                <string>punctuation.definition.comment.end.plain</string>
            </dict>
        </dict>
      </dict>
    </array>
    <key>scopeName</key>
    <string>text.plain</string>
  </dict>
</plist>
0 Likes

#9

Does not work. But it is ok. Change in Plain text.sublime-syntax works fine. Thank you

0 Likes