[OT] vim tip with column limits

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Oct 9 00:24:02 UTC 2017


I've wanted this for ages and just figured out how to do it, so I figured
that I'd share for those vim users who care.

The :set cc=x command lets you put a vertical line in vim (cc standing for
colorcolumn). e.g. if there's a line limit of 80 characters, if you do
:set cc=81, then there will be a vertical red line on column 81, so anything
left of the red line is good, and if you're on the red line or beyond it,
you've gone too far. That makes it _way_ easier to deal with line limits
than it would be otherwise.

That's all well and good, and I've known that for ages. The problem is that
I've wanted two vertical lines. Phobos has a soft line limit of 80
characters and a hard line limit of 120, and we try and keep documentation
comments within 80. So, ideally, I'd have a vertical line on column 81 and
one on 121. But there's only one cc. So, I've had to keep resetting cc
depending on whether I wanted to see where the soft limit / documentation
limit was or where the hard limit was. And that's annoying.

However, I just went digging around again to see if I could find an
alternate solution, and I've now figured out that while there is only one cc
you can set, you can actually give it multiple values. e.g. :set cc=81,121
will give you vertical lines on both columns 81 and 121, which is exactly
what I've been trying to do (and you can provide more comma-separate numbers
if you have a reason for more than two lines).

So, now I can just set cc once, rather than having to adjust it
periodically.

It would be nice if I could give the lines different colors (it does look
like it's possible to change the colors of the lines but not individually),
but it's already fantastic that there's a way to have multiple at all -
particularly since I had no clue before that that was even possible.

- Jonathan M Davis



More information about the Digitalmars-d mailing list