Provide 'colorcolumn' option maps on "t"

Resolves: https://github.com/tpope/vim-unimpaired/pull/203
Resolves: https://github.com/tpope/vim-unimpaired/pull/224
This commit is contained in:
Tim Pope
2022-04-28 22:05:14 -04:00
parent a1fd1f02f1
commit e52cb4d77f
2 changed files with 11 additions and 0 deletions

View File

@@ -86,6 +86,7 @@ On Off Toggle Option
*[on* *]on* *yon* 'number'
*[or* *]or* *yor* 'relativenumber'
*[os* *]os* *yos* 'spell'
*[ot* *]ot* *yot* 'colorcolumn' ("+1" or last used value)
*[ou* *]ou* *you* 'cursorcolumn'
*[ov* *]ov* *yov* 'virtualedit'
*[ow* *]ow* *yow* 'wrap'

View File

@@ -346,6 +346,16 @@ nmap <script> <Plug>(unimpaired-enable)+ :<C-U>set cursorline cursorcolumn<CR>
nmap <script> <Plug>(unimpaired-disable)+ :<C-U>set nocursorline nocursorcolumn<CR>
nmap <script> <Plug>(unimpaired-toggle)+ :<C-U>set <C-R>=<SID>CursorOptions()<CR><CR>
function! s:ColorColumn(should_clear) abort
if !empty(&colorcolumn)
let s:colorcolumn = &colorcolumn
endif
return a:should_clear ? '' : get(s:, 'colorcolumn', get(g:, 'unimpaired_colorcolumn', '+1'))
endfunction
nmap <script> <Plug>(unimpaired-enable)t :<C-U>set colorcolumn=<C-R>=<SID>ColorColumn(0)<CR><CR>
nmap <script> <Plug>(unimpaired-disable)t :<C-U>set colorcolumn=<C-R>=<SID>ColorColumn(1)<CR><CR>
nmap <script> <Plug>(unimpaired-toggle)t :<C-U>set colorcolumn=<C-R>=<SID>ColorColumn(!empty(&cc))<CR><CR>
exe s:Map('n', 'yo', '<Plug>(unimpaired-toggle)')
exe s:Map('n', '[o', '<Plug>(unimpaired-enable)')
exe s:Map('n', ']o', '<Plug>(unimpaired-disable)')