代码之家  ›  专栏  ›  技术社区  ›  terrace

用于在Vim中突出显示缩进项目符号的正则表达式

  •  2
  • terrace  · 技术社区  · 16 年前

    项目符号字符,而不是前面的空白。

    如果前面有^\s\{0,1}(但是 不要 匹配空格“

    使用以下匹配规则,

    syn match notesBullet /^\s*\*/
    hi def link notesBullet String 
    syn match notesNumber /^\s*\d*\./
    hi def link notesNumber String
    syn match notesMinus /^\s*\-/
    hi def link notesMinus Todo 
    syn match notesPlus /^\s*+/
    hi def link notesPlus Plus

    在Vim regex中是否有某种方式表示“if前面加了,但不包括”?

    2 回复  |  直到 6 年前
        1
  •  3
  •   Jay    16 年前

    除了Alex提到的lookaround之外,Vim模式还有“match start”和“match end”的概念,用 \zs 和 \ze 和\或之后 \泽 (您不必指定两者)从匹配。

    所以你可以加上 \zs公司 在空白模式之后,在项目符号/数字模式之前。例如: /^\s*\zs\d*\./

        2
  •  2
  •   Alex Martelli    16 年前

    有没有办法说“如果 在Vim regex里?

    是的,这叫做“零宽度”匹配, \@<= here 所有细节。