digitalmars.D - [OT] vim tip with column limits
- Jonathan M Davis (28/28) Oct 08 2017 I've wanted this for ages and just figured out how to do it, so I figure...
- Anonymouse (3/10) Oct 08 2017 Big thanks. Still exploring vim and this is something I hadn't
- lobo (5/8) Oct 08 2017 This presentation gave me a few vim ideas, you might also like it.
- Jonathan M Davis (4/11) Oct 08 2017 That was a good video. It's always kind of funny how much work programme...
- Steven Schveighoffer (6/30) Oct 08 2017 Very nice!
- Anton Pastukhov (3/5) Oct 09 2017 https://github.com/nathanaelkane/vim-indent-guides allows to have
- mark_mcs (5/10) Oct 09 2017 I didn't even know about cc. I've always used a custom
- lithium iodate (2/3) Oct 09 2017 Thanks for the tip!
- Eduard Staniloiu (6/10) Oct 11 2017 You might also want to use automatic word wrapping [0] for 120
- Jonathan M Davis (15/27) Oct 11 2017 That's also potentially a viable solution, but personally, I've never
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
Oct 08 2017
On Monday, 9 October 2017 at 00:24:02 UTC, Jonathan M Davis wrote: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).Big thanks. Still exploring vim and this is something I hadn't thought possible.
Oct 08 2017
On Monday, 9 October 2017 at 00:24:02 UTC, 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. [...]This presentation gave me a few vim ideas, you might also like it. https://www.youtube.com/watch?v=aHm36-na4-4 bye, lobo
Oct 08 2017
On Monday, October 09, 2017 02:03:16 lobo via Digitalmars-d wrote:On Monday, 9 October 2017 at 00:24:02 UTC, Jonathan M Davis wrote:That was a good video. It's always kind of funny how much work programmers will go to, because they're lazy. :) - Jonathan M DavisI'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. [...]This presentation gave me a few vim ideas, you might also like it. https://www.youtube.com/watch?v=aHm36-na4-4
Oct 08 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
Oct 08 2017
On Monday, 9 October 2017 at 00:24:02 UTC, 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.https://github.com/nathanaelkane/vim-indent-guides allows to have two or more lines of different colors.
Oct 09 2017
On Monday, 9 October 2017 at 00:24:02 UTC, Jonathan M Davis wrote: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.I didn't even know about cc. I've always used a custom highlighter for this: hi LineLimit ctermbg=red ctermfg=white guibg=#be322f match LineLimit /\%121v/
Oct 09 2017
On Monday, 9 October 2017 at 00:24:02 UTC, Jonathan M Davis wrote:[…]Thanks for the tip!
Oct 09 2017
On Monday, 9 October 2017 at 13:38:18 UTC, lithium iodate wrote:On Monday, 9 October 2017 at 00:24:02 UTC, Jonathan M Davis wrote:You might also want to use automatic word wrapping [0] for 120 chars. Cheers, Eduard [0] - http://vim.wikia.com/wiki/Automatic_word_wrapping[…]Thanks for the tip!
Oct 11 2017
On Wednesday, October 11, 2017 07:59:51 Eduard Staniloiu via Digitalmars-d wrote:On Monday, 9 October 2017 at 13:38:18 UTC, lithium iodate wrote:That's also potentially a viable solution, but personally, I've never particularly liked how vim's word wrapping behaves, and I've generally avoided it. Simply knowing where the line limits are so that I know when I've gone too far works well for me. Other really useful stuff along those lines has been highlighting tabs and any trailing whitespace in red. So, I always know that it's there and needs to be removed (though that meant that I had to adjust my .vimrc when I was unlucky enough to have to use tabs where I was working). I don't generally have vim do much for me automatically (cindent is about the only automatic behavior that I have on that I can think of). Rather, I know what commands I need to do what I want or add commands that do it if that helps my productivity, and then I use the commands when I need them. - Jonathan M DavisOn Monday, 9 October 2017 at 00:24:02 UTC, Jonathan M Davis wrote:You might also want to use automatic word wrapping [0] for 120 chars. Cheers, Eduard [0] - http://vim.wikia.com/wiki/Automatic_word_wrapping[…]Thanks for the tip!
Oct 11 2017