【问题标题】:How do you make Sublime Text 3 toggle comments on/off for Fortran?你如何让 Sublime Text 3 为 Fortran 打开/关闭评论?
【发布时间】:2021-07-12 08:54:41
【问题描述】:

我为 Fortran 编写了一个语法高亮器,它可以正确地高亮 cmets。问题是ctrl+/ 快捷方式无法打开或关闭 cmets。

我需要添加一些特定的设置来启用它吗?

作为参考,我使用了 Sublime 提供的标准 *.sublime-syntax 文件结构来构建荧光笔。所以,它看起来像:

%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions: [f]
scope: source.fortran
contexts:
  main:
    # Comments begin with a '!' and finish at the end of the line
    - match: '!'
      scope: punctuation.definition.comment.fortran
      push: line_comment

  line_comment:
    - meta_scope: comment.line.fortran
    - match: $
      pop: true

另外,我在 RedHat 7 上使用它。

【问题讨论】:

    标签: fortran sublimetext3


    【解决方案1】:

    您需要在与您的Fortran.sublime-syntax 文件相同的文件夹中创建一个名为Comments.tmPreferences 的文件,其内容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>name</key>
        <string>Comments</string>
        <key>scope</key>
        <string>source.fortran</string>
        <key>settings</key>
        <dict>
            <key>shellVariables</key>
            <array>
                <dict>
                    <key>name</key>
                    <string>TM_COMMENT_START</string>
                    <key>value</key>
                    <string>! </string>
                </dict>
            </array>
        </dict>
        <key>uuid</key>
        <string>65507EAD-D547-44E4-84F7-7D421DD078B0</string>
    </dict>
    </plist>
    

    我认为 Sublime 不需要 UUID(这些文件最初是为在 Mac 编辑器 TextMate 中使用而开发的),所以如果你愿意,可以随意摆脱它。除此之外,这应该做你想做的事 - 当你点击 Ctrl/ 时,在任何选定行的开头插入 !

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 2015-11-20
      • 2016-04-13
      • 1970-01-01
      • 2011-11-24
      • 1970-01-01
      相关资源
      最近更新 更多