Skip to content

regex anchors and character classes in ZSH_HIGHLIGHT_REGEXP keys not matching #768

Closed
@olets

Description

@olets

I'm not having success with ZSH_HIGHLIGHT_REGEXP keys that include \s, \b, \n, or \w. I haven't tried other anchors or character classes. I have tried escaping the \ as \\ with no success.

For example following https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/regexp.md:

typeset -A ZSH_HIGHLIGHT_REGEXP
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main regexp)
ZSH_HIGHLIGHT_REGEXP+=('\bmytest\b' fg=blue)

mytest never highlights.

My goal is two matches: words that are the single word in a no-trailing-whitespace buffer

ZSH_HIGHLIGHT_REGEXP+=('^[\s\n]*(one|two)$' fg=blue)

and words that are the last in a no-trailing-whitespace buffer

ZSH_HIGHLIGHT_REGEXP+=('\b(three|four)$' fg=red)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions