如何在 Vim 中使用一种语法突出显示和两种颜色以及两种不同的开始/结束集?
假设我有一个文件:memovi.txt(学习 vi...),其中每一行都有相同的结构(命令冒号解释);例如 :
dw : 从当前光标位置删除到下一个单词
(注意:文本白色,背景黑色)
现在,我想做两件事:
1)以绿色突出显示命令 我通过定义一个带有开始和结束的区域来做到这一点,我用开始=≈和结束=≈
所以,在我的.vimrc中我有:
:command Tran :source syntax.vim
在我的syntax.vim中,我有:
syn region cTran conceal start='≈' end='≈'
hi cTran ctermbg=Black ctermfg=DarkGreen
2)但我希望,当然,要插入一个示例(例如 d4w),并以不同的颜色(洋红色)突出显示它,我想通过将其放在 start=• 和 end=• 之间来突出显示它 带来如下结果:
≈dw≈(因此呈绿色):从当前光标位置删除到 下一个词。 •d4w•(因此为洋红色):删除 4 个单词
但似乎我无法根据两个不同的开始/结束集定义一种使用两种不同“颜色”突出显示的语法。或者我可以吗?
提前致谢
Let us say I have a file : memovi.txt (to learn vi...) in which each line has the same structure (command colon explanation) ; for example :
dw : Deletes from the current cursor location to the next word
(NB : text white, background black)
Now, I want to do 2 things :
1) highlight the command in green
I did it by defining a region with start and end, which I did with start=≈, and end=≈
So, in my .vimrc I have :
:command Tran :source syntax.vim
and in my syntax.vim, I have :
syn region cTran conceal start='≈' end='≈'
hi cTran ctermbg=Black ctermfg=DarkGreen
2) but I wish, of course, to insert an example (eg, d4w), and highlight it in a different color (magenta), and I would like to highlight it by putting it between start=• and end=•
to bring a result such as :
≈dw≈ (thus in green) : Deletes from the current cursor location to the
next word. •d4w• (thus in magenta) : delete 4 words
But it seems I cannot define one syntax highlighting with two different "coloring" depending on two different start/end sets. Or can I ?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
vim 帮助文件语法 (help.vim) 是这种行为的一个很好的模板。它使用“|”栏分隔帮助超链接。然后酒吧被隐藏。
这是syntax.vim,它应该实现您想要的 ASCII 分隔符
|
和=
的效果。我还没有用你的 Unicode 字符测试过它,但我不明白为什么要改变任何东西(尽管我对 Unicode 的变幻莫测没有受过教育)。希望这有帮助。
The vim help file syntax (help.vim) is a good template for this behaviour. It uses the bar "|" to delimit help hyperlinks. The bar is then concealed.
Here is the syntax.vim which should achieve what you want for the ASCII delimiters
|
and=
. I haven't tested it with your Unicode characters, but I can't see why anything should change (although I am unschooled in the vagaries of Unicode).Hope this helps.