Simplify colorcolumn handling

This commit is contained in:
Anthony Rose 2025-01-27 15:02:20 +00:00
parent c379cdec0e
commit 4aad9e5e6a

11
vimrc
View file

@ -77,8 +77,8 @@ map <ScrollWheelUp> 3<C-Y>
" larger than the textwidth. E.g. to include a 'margin-bell' line also: " larger than the textwidth. E.g. to include a 'margin-bell' line also:
" set tw=80 cc=73,81 " set tw=80 cc=73,81
" Clear the colorcolumn highlighting with cc=0. " Clear the colorcolumn highlighting with cc=0.
set colorcolumn=0 set textwidth=80 " Suggestions: 72, 80, 100
set textwidth=0 " Suggestions: 72, 80, 100 execute "set colorcolumn=" . (&textwidth + 1)
" All other settings. " All other settings.
set autoindent set autoindent
@ -148,8 +148,8 @@ if has('eval')
let loaded_netrwPlugin=1 let loaded_netrwPlugin=1
function! ACPToggleMargins() function! ACPToggleMargins()
execute "set colorcolumn=" . (&colorcolumn == "0" ? "73,81" : (&colorcolumn == "73,81" ? "101" : "0")) execute "set textwidth=" . (&textwidth == "80" ? "72" : (&textwidth == "72" ? "100" : "80"))
execute "set textwidth=" . (&colorcolumn == "73,81" ? "80" : (&colorcolumn == "101" ? "100" : "0")) execute "set colorcolumn=" . (&textwidth + 1)
echo "tw=" . &textwidth . " & cc=" . &colorcolumn echo "tw=" . &textwidth . " & cc=" . &colorcolumn
endfunction endfunction
@ -242,6 +242,9 @@ if has('autocmd')
autocmd BufRead,BufNewFile *.xml set et sw=2 autocmd BufRead,BufNewFile *.xml set et sw=2
autocmd BufRead,BufNewFile *.yaml set et sw=2 autocmd BufRead,BufNewFile *.yaml set et sw=2
autocmd BufRead,BufNewFile *.yml set et sw=2 autocmd BufRead,BufNewFile *.yml set et sw=2
" Set colorcolumn after the file has been loaded.
autocmd VimEnter * execute "set colorcolumn=" . (&textwidth + 1)
endif endif
if has('clipboard') if has('clipboard')