在 Vim 中显示超过 80 个字符的不同背景颜色 [英] Showing a different background colour in Vim past 80 characters

查看:19
本文介绍了在 Vim 中显示超过 80 个字符的不同背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到 配色方案.你可以找到我的 vim 配置 和我所有的 dotfiles 在 GitHub 上.

I have seen Vim 80 column layout concerns, but the answer there highlights only actual content that goes over the 80 character mark. I want to have a 100+ column Vim window open with the leftmost 80 columns using the normal background and anything past that using a slightly different background. The Vim window background should be a different color, not just text that goes over the 80 character point. This would indicate how close I am getting to the 80-char point without having to go over it first.

I don't think this is currently possible, but I thought I'd ask just in case.

Maybe it could be done with a plugin?

TextMate Example of Desired Vim Right Margin Highlighting

By selecting "Highlight right margin" in TextMate's general preferences, you can see an example of the desired Vim behavior.

解决方案

If you have Vim >= v7.3, you can simply add this to your .vimrc to highlight 81 and onward (so 80 is your last valid column):

let &colorcolumn=join(range(81,999),",")

If you don't see a highlight, you may not have a ColorColumn highlight color set. Add this (adjust to suit your preferences):

highlight ColorColumn ctermbg=235 guibg=#2c2d27

Now I like to highlight column 80 as well as 120 and onward, so I have separate "warning" and "danger" markers. You can do that thusly:

let &colorcolumn="80,".join(range(120,999),",")

Example

Here's a screenshot of GVim editing my .vimrc.

I use Ubuntu Mono 11 font and the molokai color scheme. You can find my vim config and all of my dotfiles on GitHub.

这篇关于在 Vim 中显示超过 80 个字符的不同背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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