在 Vim 中启用 Markdown 突出显示 [英] Enabling markdown highlighting in Vim
问题描述
我在装有 OS X Lion 的 MacBook Air 的终端中使用 Vim,但似乎找不到用于 Markdown 语法突出显示的好插件.
到目前为止,我已经尝试了 plasticboy 插件和 Tim Pope 的插件.塑料男孩插件工作正常,但导致行尾的空白被突出显示,我还没有想出如何关闭它.(这真的很烦人,因为每次我在写它时按 space
都会突出显示字符.)
Tim 的插件在突出显示方面似乎没有太多作用,除了可能使用 ###
的标题.代码块和项目符号被忽略.我可能在那里遗漏了一些东西.我确实在 Markdown 文件上使用了 .md
扩展名,所以它应该选择文件类型.
我还看到了对内置 Markdown 支持的 Vim 7.3 的引用,但如果没有这两个插件中的一个,我根本没有得到任何突出显示.
这些是否需要特定的配色方案才能工作?
这应该可以在使用塑料男孩 mkd 插件时禁用行尾空格突出显示:
:syn clear mkdLineBreak
您可以autocmd
为必要的文件扩展名设置,这样您就不必每次加载降价文件时都这样做.
注意,这个特殊的高亮存在是因为 Markdown 通过插入 <br>
来特殊处理以 2 个或更多空格字符结尾的行,所以它很有用.>
plasticboy 插件使用 TODO
突出显示这条规则,这有点太多了,因为它的设计目的是,默认情况下,非常花哨 - 黄色背景 - 所以它脱颖而出.您可以通过更改 highlight
规则来减少视觉冲击.一种快速的方法是:
:hi 链接 mkdLineBreak 下划线
现在这些行尾空格将显示为下划线.尝试链接到其他 highlight
组以获得可能更吸引您的内容.除了使用 link
,您还可以更具体地了解那些行尾空间:例如,您可以使用自己的 highlight
命令,指定自定义 ctermfg、ctermbg、guifg、guibg 设置.>
如上所述,您可以autocmd
来应用您的特定设置.
有关链接 highlight
组的更多信息,请键入::help group-name
,您将看到可以链接的组列表,这些组本身应该有助于使用他们当前的 highlight
规则显示.还有::help highlight
.
I'm using Vim in a terminal on my MacBook Air with OS X Lion, and I can't seem to find a good plugin for Markdown syntax highlighting.
So far I've tried the plasticboy plugin and Tim Pope's plugin. The plasticboy plugin worked OK but was causing white space at the end of lines to be highlighted, and I haven't figured out how to turn that off. (It's really annoying, because every time I hit space
when I'm writing it highlights the character.)
Tim's plugin didn't seem to do very much in the way of highlighting, other than maybe headers that use ###
. Code blocks and bullets are ignored. I might be missing something there. I do use the .md
extension on my Markdown files, so it should be picking up the filetype.
I've also seen a reference to Vim 7.3 having Markdown support built in, but without one of those two plugins I don't get any highlighting at all.
Do either of these require specific color schemes to work?
This should work to disable the end-of-line space highlighting when using the plasticboy mkd plugin:
:syn clear mkdLineBreak
You could autocmd
that for the necessary file extensions so that you needn't do it every time you load a markdown file.
Note that this specific highlight exists because Markdown treats lines ending with 2 or more space characters specially by inserting a <br>
, so it is useful.
The plasticboy plugin uses TODO
highlighting for this rule, which is a bit too much as it's designed to, by default, be really garish - yellow background - so that it stands out. You can make this less visually striking by changing that highlight
rule. One quick way to do this would be something like:
:hi link mkdLineBreak Underlined
Now those end-of-line spaces will show up as underlined. Try linking to other highlight
groups for something that may appeal to you more. Instead of using link
you can get even more specific about those end-of-line spaces: for instance you could specify that they show up as just slightly lighter/darker than the normal background, using your own highlight
command, specifying custom ctermfg, ctermbg, guifg, guibg settings.
As above, you could autocmd
this to apply your specific settings.
For more information about link highlight
groups, type: :help group-name
and you'll see a list of groups that can be linked that themselves should helpfully be displayed using their current highlight
rules. Also: :help highlight
.
这篇关于在 Vim 中启用 Markdown 突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!