Vim 语法高亮隐藏字符
我想为 vim 实现一个语法文件,隐藏文件中的某些字符。具体来说,我想编写一个改进的荧光笔来读取 Markdown 文件,该文件不显示某些格式字符,而是更喜欢隐式指示它们。例如,我希望将 *bold*
之类的内容渲染为带有粗体文本的简单 bold
,或者使标题
My Header
=========
不显示下划线,而只显示不同的颜色。到目前为止,我还没有找到任何 vim 语法文件的示例来隐藏特定字符的显示。这在vim中是可能的吗?如果是这样,怎么办?
I'd like to implement a syntax file for vim that hides certain characters in the file. Specifically, I want to write an improved highlighter for reading Markdown files that doesn't display some of the formatting characters, preferring instead to indicate them implicitly. For example, I'd like to have things like *bold*
render as simply bold
with bold text, or to have headings like
My Header
=========
not show their underline, but just appear a different color. I haven't managed to find any examples so far of vim syntax files that hide specific characters from display. Is this something that is possible in vim? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要隐藏语法项 - 或仅隐藏某些字符 - 可以使用隐藏或忽略参数。有关
示例,请参阅语法文件“help.vim”,它是 crefvim< 的一部分/a>. CRefVim 是嵌入在 Vim 帮助系统中的 C 语言参考手册。 “help.vim”语法文件扩展了帮助文件的标准语法突出显示。
一个例子。这里使用 '$' 字符以斜体显示文本:
也许这个例子是您进一步挖掘的一个很好的起点......
哈比
To hide syntax items - or just certain characters - the conceal or Ignore arguments can be used. See
For an example see the syntax file "help.vim" which is part of crefvim. CRefVim is a C-reference manual which is embedded in the Vim help system. The "help.vim" syntax file extends the standard syntax highlighting for help files.
An example. The '$' character is used here to show text in italic:
Maybe this example is a good starting point for you to dig further...
Habi
您可以使用“粗体”、“斜体”等,使用相应的颜色主题制作自己的语法文件。它不会隐藏任何内容,因此您的语法必须与原始文本兼容。
例如,这可能是您的标题语法
在您的语法中,您需要:
并且在颜色主题中
,这样的标题
将显示为粗体,根本没有任何标记。顺便说一下,您可以使用 TOhtml 功能导出它,同时保持突出显示。
You could make your own syntaxfile with an according colortheme, using "bold", "italics" and the like. It wouldn't hide anything, so that your syntax must work with the original text.
For example this could be your syntax for headers
In your syntax you would need:
and in the colortheme
then a header like this
would be shown bold, without any markup at all. By the way, you can export it with the TOhtml feature while keeping the highlighting.