【问题标题】:How to enable #TODO/XXX/FIXME highlight in Spyder?如何在 Spyder 中启用#TODO/XXX/FIXME 高亮显示?
【发布时间】:2015-07-02 02:34:11
【问题描述】:

我正在使用 Spyder 进行 Python 编码。但是,我不能让#TODO/#FIXME/#XXX 的亮点在 Spyder 中工作。我已经在首选项设置中选中了该框。见附图。

有什么提示吗?谢谢。

【问题讨论】:

  • 你试过### TODO:吗?
  • 感谢您的提示。在末尾添加: 后,所有这些现在都被识别为突出显示。

标签: python python-2.7 ide spyder


【解决方案1】:

: 添加到您的关键字中,例如# TODO:

【讨论】:

    【解决方案2】:

    使用 spyder 的新版本 (4..) 它可以正常工作,无需任何添加

    #TODO
    #FIXME
    

    【讨论】:

      【解决方案3】:

      好的,所以我深入研究了这个问题,这是真正的答案: 截至2020年2月,相关代码可以在https://github.com/spyder-ide/spyder/blob/aa9fdaf7379577bdc7c2aa1e2bdc3feb82be953b/spyder/utils/syntaxhighlighters.py line 492左右找到,例如

          OECOMMENT = re.compile(r'^(# ?--[-]+|##[#]+ )[ -]*[^- ]+')
      

      所以,为了让 Spyder 大纲浏览器 (OE) 识别您的评论,它应该

      1. Start from the head of the line
      2. Begin with either "#---" or "### " (be careful of the mandatory space)
      3. Then optional spaces or "-", 
      4. Then some more charactors that is NOT "-".
      

      以下是工作示例(在 Spyder 4.0.1 上测试)

      ### foo
      #--- bar
      ############# foo
      # ---    bar
      ### ----foobar
      #------------ foofoo
      

      【讨论】:

      • 并非如此。如果您尝试在 PyCharm 中打开带有 spyder 突出显示的 cmets 的文件,它会特别抱怨这一点。
      猜你喜欢
      • 2011-05-22
      • 2011-05-05
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      • 2020-03-13
      • 2011-08-28
      • 1970-01-01
      相关资源
      最近更新 更多