在Vim中启用markdown突出显示 [英] Enabling markdown highlighting in Vim

查看:202
本文介绍了在Vim中启用markdown突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在装有OS X Lion的MacBook Air的终端中使用Vim,但似乎找不到适合Markdown语法突出显示的好插件.

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.

到目前为止,我已经尝试使用 plasticboy 插件和

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的插件似乎并没有在突出显示方面做很多事情,除了可能使用###的标头.代码块和项目符号将被忽略.我可能在那里丢失了一些东西.我在Markdown文件上确实使用了.md扩展名,因此它应该选择文件类型.

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.

我还看到了内置了Markdown支持的Vim 7.3参考,但是如果没有这两个插件之一,我根本就不会突出显示任何内容.

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?

推荐答案

在使用plasticboy mkd插件时,这应该可以禁用行尾空格突出显示:

This should work to disable the end-of-line space highlighting when using the plasticboy mkd plugin:

:syn clear mkdLineBreak

对于必要的文件扩展名,您可以autocmd,这样就不必在每次加载降价文件时都这样做.

You could autocmd that for the necessary file extensions so that you needn't do it every time you load a markdown file.

注意,因为Markdown通过插入<br>来特别对待以2个或更多空格字符结尾的行,所以存在此特定的突出显示,因此很有用.

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.

plasticboy插件为此规则使用TODO加亮显示, 有点过分,因为它的设计默认情况下非常扎眼-黄色背景-因此突出.您可以通过更改highlight规则来减少视觉冲击.一种快速的方法是:

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

现在,这些行尾空格将显示为带下划线的.尝试链接到其他highlight组,以获得可能更吸引您的东西.除了使用link之外,您还可以更详细地了解这些行尾空格:例如,您可以使用自己的highlight命令,指定它们显示的颜色比正常背景略浅/暗.自定义 ctermfg ctermbg guifg guibg 设置.

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.

如上所述,您可以autocmd来应用您的特定设置.

As above, you could autocmd this to apply your specific settings.

有关链接highlight组的更多信息,请键入::help group-name,您将看到可以链接的组列表,这些组应该使用其当前的highlight规则显示出来.另外::help highlight.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆