[OT] vim tip with column limits

Steven Schveighoffer schveiguy at yahoo.com
Mon Oct 9 02:25:52 UTC 2017


On 10/8/17 8:24 PM, Jonathan M Davis wrote:
> 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).

Very nice!

I typically just format lines with :gql (I have it mapped to capital K)

So I don't typically need a visual indicator, as long as I don't forget 
to reformat a line. But I will try with this to see how it goes.

-Steve


More information about the Digitalmars-d mailing list