Vim语法着色:如何突出长线? [英] Vim syntax coloring: How do I highlight long lines only?

查看:137
本文介绍了Vim语法着色:如何突出长线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望vim为我着色长的线条。使用80列作为示例,我想突出显示超过该长度的行。这里大致是我认为.vimrc文件应该包含,虽然它(1)不工作,和(2)使用Perl的regex语法来说明我的观点,因为我不知道Vim的足够:

I would like vim to color "long" lines for me. Using 80 columns as an example, I would like to highlight lines that exceed that length. Here is roughly what I think the .vimrc file should contain, although it (1) doesn't work, and (2) uses Perl's regex syntax to illustrate my point, because I don't know Vim's well enough:

...
highlight Excess ctermbg=0
au Syntax * syn match Excess /.{80,}$/
...



这个(至少在我看来)应该标记超过80列。我最喜欢的是只能对超过80列的行的颜色进行着色,因此如果一行是85列,那么第81列到第85列将被突出显示。

This (in my mind at least) should mark lines that exceed 80 columns. What I would ideally like is the ability to color only the part of the line that exceeds 80 columns, so if a line is 85 columns, then the 81st through the 85th columns would be highlighted.

我相信Vim可以做到这一点,只是不在掌舵。

I'm sure Vim can do this, just not with me at the helm.

推荐答案

在我的vimrc。

我在这里找到: Vim 80列布局关注

highlight OverLength ctermbg=darkred ctermfg=white guibg=#FFD9D9
match OverLength /\%81v.*/

您可能想根据偏好调整颜色。

You might want to adjust the colors to your preferences.

这篇关于Vim语法着色:如何突出长线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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