tommcdo/vim-exchange

Option for disabling highlighting

kiryph opened this issue · 5 comments

Occasionally, I don't like to see the highlighting which in general is very helpful.
For instance, if you are working with someone together and don't want to distract
the other person by visual highlightings in your editor.

It sounds like you want a one-off way to disable highlighting, meaning you can interactively toggle whether exchange uses highlighting. To me, this sounds like a lot of work for little payoff.

A workaround could be to temporarily link the ExchangeRegion highlighting group to one with no special highlighting. (Unfortunately, I'm unable to find a good candidate at the moment.) You can do this using

:hi link ExchangeRegion <some other highlight group>

Normal would be a good candidate for the highlighting group to link to:

:hi link ExchangeRegion Normal

Alternatively one can remove a link by

:hi link ExchangeRegion NONE  

And yes I'd like to have a mapping to easily toggle it.

Following mapping inspired by unimpaired.vim would do the trick:

nnoremap [oe :hi link ExchangeRegion NONE<CR>
nnoremap ]oe :hi link ExchangeRegion IncSearch<CR>
nnoremap coe :call HighlightExchangeRegionToggle()<cr>
let g:highlight_exchangeregion = 1
function! HighlightExchangeRegionToggle()
    if g:highlight_exchangeregion
        hi link ExchangeRegion IncSearch
        let g:highlight_exchangeregion = 0
    else
        hi link ExchangeRegion NONE
        let g:highlight_exchangeregion = 1
    endif
endfunction

Thanks for pointing me into the right direction.

Of course, I'd appreciate this built in your plugin. But if you haven't missed this feature, you won't need it. At the moment I think I keep it most time switched on, but occasionally I will turn it off.

I think I'll add this functionality.

I won't create Normal mode mappings, since this feels more like a :-command use case. It seems appropriate to leave it to the end user to create these mappings if he wants. Your suggestion to follow the unimpaired.vim style is an excellent choice for personal use, but I wouldn't want to step on that namespace in my plugin.

👍 for :XchangeHighlightToggle and friends.

A colon command instead of a normal command is certainly good enough. And not stepping on this namespace, I guess, is a sensible choice.

Thanks for adding the command.