@blastmaster Does that set textwidth to columncolor? 1. I want it the other way around, and 2. when loading the vimrc in a new vim session, the textwidth is not set yet.
Conversation
Notices
-
FlowFX (flowfx@chaos.social)'s status on Thursday, 24-Jan-2019 11:15:56 CET FlowFX -
FlowFX (flowfx@chaos.social)'s status on Thursday, 24-Jan-2019 10:45:48 CET FlowFX #Vim question: how do I set `colorcolumn` to the current `textwidth`?
Textwidth is set either in a config file or by the editorconfig-vim plugin or sth like it.
Right now I only know how to set colorcolumn manually (or fixed value in the vimrc). There has to be a better way!
-
FlowFX (flowfx@chaos.social)'s status on Thursday, 24-Jan-2019 11:18:41 CET FlowFX @blastmaster Or I just don't know what I'm talking about.
-
nahtaiv3L (l3viathan@mastodon.social)'s status on Thursday, 24-Jan-2019 12:56:35 CET nahtaiv3L @flowfx @blastmaster You can create an autocommand for the event OptionSet
FlowFX repeated this. -
FlowFX (flowfx@chaos.social)'s status on Thursday, 24-Jan-2019 15:01:13 CET FlowFX So thanks to @l3viathan and @blastmaster I learned about Vim's :autocmd today. :)
This works for me:
:autocmd FileType python,ruby let &colorcolumn=&textwidth
Actually, the trigger isn't really relevatn. It would work with OptionSet and BufRead as well.
Yay! :)
-
blabber (blabber@chaos.social)'s status on Thursday, 24-Jan-2019 15:10:54 CET blabber @flowfx FYI: colorcolumn kannst du auch relativ zu textwidth setzen. Wenn du colorcolumn auf +0 setzt, passt sich das automatisch an die textwidth an.
Das steht bei mir pauschal in der vimrc. Wenn keine textwidth gesetzt ist, habe ich keine farbige Spalte, wenn eine gesetzt ist wird mir die entsprechende Spalte eingefärbt.
FlowFX repeated this. -
blabber (blabber@chaos.social)'s status on Thursday, 24-Jan-2019 15:18:01 CET blabber @flowfx Relatiert: https://github.com/vim/vim/blob/135059724f140ceac889c9f8136bd1bf5c41d49d/runtime/doc/options.txt#L1715-L1716
FlowFX repeated this. -
FlowFX (flowfx@chaos.social)'s status on Thursday, 24-Jan-2019 15:18:28 CET FlowFX And that's why I ask stupid questions.
The simple answer comes from @blabber, and it's:
set colorcolumn=+0
-
FlowFX (flowfx@chaos.social)'s status on Thursday, 24-Jan-2019 15:18:54 CET FlowFX @blabber DANKE!!!
-