In my .vimrc, I have:
:au BufWinEnter * let w:m1=matchadd('Search', '\%>80v.\+', -1)
to highlight lines that stray over the 80 character limit. How can I set it so that this is toggled on/off by pressing a function key?
Use mappings.
To activate highlight:
:nnoremap <leader>1 :match Search '\%>80v.\+'<CR>
To deactivate it:
:nnoremap <leader>2 :match none<CR>
UPDATE to use same key/key combination to toggle highlight:
let s:activatedh = 0
function! ToggleH()
if s:activatedh == 0
let s:activatedh = 1
match Search '\%>80v.\+'
else
let s:activatedh = 0
match none
endif
endfunction
nnoremap <leader>1 :call ToggleH()<CR>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With