vim-unimpaired
vim-unimpaired copied to clipboard
Mappings for conceallevel=1 toggling
Another toggling addition for unimpaired:
diff --git a/plugin/unimpaired.vim b/plugin/unimpaired.vim
index f2c90bb..b7b6d6c 100644
--- a/plugin/unimpaired.vim
+++ b/plugin/unimpaired.vim
@@ -222,6 +222,9 @@ call s:option_map('u', 'cursorcolumn', 'setlocal')
nnoremap [od :diffthis<CR>
nnoremap ]od :diffoff<CR>
nnoremap cod :<C-R>=&diff ? 'diffoff' : 'diffthis'<CR><CR>
+nnoremap [oe :set conceallevel=1<CR>
+nnoremap ]oe :set conceallevel=0<CR>
+nnoremap coe :set <C-R>=&conceallevel ? 'conceallevel=0' : 'conceallevel=1'<CR><CR>
call s:option_map('h', 'hlsearch', 'set')
call s:option_map('i', 'ignorecase', 'set')
call s:option_map('l', 'list', 'setlocal')
Any chance this get merged in? Feel free to pick a different character instead of e
.
The mappings could be changed to cycle through the levels.
Feels to me like 2 would be the more appropriate choice? That's the value that most accurately implements the syntax highlighter's intentions.
Yes, I agree with you: If a syntax highlighter does not define a conceal character, it should be understood as being done on purpose.
I actually toggle it for tex files. By default it is on: IMHO equations become more readable. But when I edit matrices, I don't want the concealment to have aligned matrix columns.
I could see making coe
toggle 2
but [oe
and ]oe
decrement and increment.
I have changed the diff:
diff --git a/doc/unimpaired.txt b/doc/unimpaired.txt
index 3d97242..f99df77 100644
--- a/doc/unimpaired.txt
+++ b/doc/unimpaired.txt
@@ -76,6 +76,7 @@ On Off Toggle Option
*[ob* *]ob* *cob* 'background' (dark is off, light is on)
*[oc* *]oc* *coc* 'cursorline'
*[od* *]od* *cod* 'diff' (actually |:diffthis| / |:diffoff|)
+*[oe* *]oe* *coe* 'conceallevel' (actually [oe and ]oe cycle)
*[oh* *]oh* *coh* 'hlsearch'
*[oi* *]oi* *coi* 'ignorecase'
*[ol* *]ol* *col* 'list'
diff --git a/plugin/unimpaired.vim b/plugin/unimpaired.vim
index f2c90bb..e2d1388 100644
--- a/plugin/unimpaired.vim
+++ b/plugin/unimpaired.vim
@@ -222,6 +222,11 @@ call s:option_map('u', 'cursorcolumn', 'setlocal')
nnoremap [od :diffthis<CR>
nnoremap ]od :diffoff<CR>
nnoremap cod :<C-R>=&diff ? 'diffoff' : 'diffthis'<CR><CR>
+" Cycle through 'conceallevel' (local to window)
+nnoremap [oe :setlocal <C-R>='conceallevel='.(&conceallevel+1)%4<CR><CR>
+nnoremap ]oe :setlocal <C-R>='conceallevel='.float2nr(&conceallevel-1-(4*floor((&conceallevel-1)/4.0)))<CR><CR>
+" Toggle between default conceallevel 2 and 0 (local to window)
+nnoremap coe :setlocal <C-R>=&conceallevel ? 'conceallevel=0' : 'conceallevel=2'<CR><CR>
call s:option_map('h', 'hlsearch', 'set')
call s:option_map('i', 'ignorecase', 'set')
call s:option_map('l', 'list', 'setlocal')
I also used 2. My bikeshed, however, uses
[o
I was looking for exactly this; can we push this into master?
Is it already there, and I missed it?
Just added this to my vimrc:
nnoremap =oe :setlocal conceallevel=<c-r>=&conceallevel == 0 ? '2' : '0'<cr><cr>
nnoremap coe :setlocal conceallevel=<c-r>=&conceallevel == 0 ? '2' : '0'<cr><cr>
nnoremap [oe :setlocal conceallevel=<c-r>=&conceallevel > 0 ? &conceallevel - 1 : 0<cr><cr>
nnoremap ]oe :setlocal conceallevel=<c-r>=&conceallevel < 2 ? &conceallevel + 1 : 2<cr><cr>
Huh ... this actually works well for the two biggest use cases; ie,
-
toggling from
&conceallevel == 0
to&conceallevel == 1
and vice versa:-
]oe
and[oe
(resp.)
-
-
toggling from
&conceallevel == 0
to&conceallevel == 2
and vice versa:-
coe
(or=oe
) and (again)coe
(or=oe
) (... resp. 😄)
-