Showing a different background colour in Vim past 80 characters

前端 未结 6 1075
陌清茗
陌清茗 2020-12-07 06:53

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

6条回答
  •  醉梦人生
    2020-12-07 07:26

    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.

    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.

提交回复
热议问题