vim 语法文件中的匹配制表符

发布于 2024-12-22 17:40:54 字数 512 浏览 0 评论 0原文

我正在使用 Vim 为我的待办事项编写语法文件 实际上,我会突出显示以 w:、h: 或 p: 开头的行,如下所示:

syn match todoHome  "^h: "
syn match todoWork  "^w: "
syn match todoPersonal  "^p: "
syn region todoHome start=/^h: / end=/\n/
syn region todoWork start=/^w: / end=/\n/
syn region todoPersonal start=/^p: / end=/\n/
syn region todoDone start=/^x: / end=/\n/

我想创建一些带有选项卡的子任务并以相同的方式突出显示它... 我知道正则表达式可以做到这一点,我尝试过:

syn region todoWork start=/^|[\t ]+w: / end=/\n/

但它不起作用......有任何线索吗?

I'm coding a syntax file for my todos with Vim
Actually i highlight the lines when they begin with w:,h: or p: like this :

syn match todoHome  "^h: "
syn match todoWork  "^w: "
syn match todoPersonal  "^p: "
syn region todoHome start=/^h: / end=/\n/
syn region todoWork start=/^w: / end=/\n/
syn region todoPersonal start=/^p: / end=/\n/
syn region todoDone start=/^x: / end=/\n/

I would like to create some subtask with tabs and highlight it in the same way...
I know regex can do that, i tried :

syn region todoWork start=/^|[\t ]+w: / end=/\n/

But it not works... Any clue ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

几味少女 2024-12-29 17:40:54

<代码>| => \|

:help pattern

1. A pattern is one or more branches, separated by "\|".  It matches anything
   that matches one of the branches.  Example: "foo\|beep" matches "foo" and
   matches "beep".  If more than one branch matches, the first one is used.

   pattern ::=      branch
        or  branch \| branch
        or  branch \| branch \| branch
        etc.

+ => \+

\+  1 or more   as many as possible (*)

或者在模式的开头添加 \v

Use of "\v" means that in the pattern after it all ASCII characters except
'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  "very magic"

| => \|

:help pattern

1. A pattern is one or more branches, separated by "\|".  It matches anything
   that matches one of the branches.  Example: "foo\|beep" matches "foo" and
   matches "beep".  If more than one branch matches, the first one is used.

   pattern ::=      branch
        or  branch \| branch
        or  branch \| branch \| branch
        etc.

+ => \+

\+  1 or more   as many as possible (*)

Or add \v at the beginning of the pattern!

Use of "\v" means that in the pattern after it all ASCII characters except
'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning.  "very magic"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文