vim-cool icon indicating copy to clipboard operation
vim-cool copied to clipboard

Toggling on/off

Open YodaEmbedding opened this issue 6 years ago • 11 comments

Sometimes, I want just want to <C-d> through a document without losing the highlights.

It would be useful to implement a command or option for toggling vim-cool on/off.

:VimCoolToggle

YodaEmbedding avatar Nov 23 '19 06:11 YodaEmbedding

Hmm, :VimCoolToggle sounds a lot like the :nohlsearch this plugin is specifically designed to eradicate.

romainl avatar Nov 23 '19 11:11 romainl

99% of the time, I want highlighting to disappear upon navigation. But there's a small 1% where it is useful to revert to the default behavior.

Imagine searching for this in a file:

this this this this

...many lines...

this this this this lorem ipsum
this this this this dolor sit
this this this this amet

...many lines...

this <-- this "this" is what we were looking for

Instead of pressing n repeatedly, it's faster to <C-f> a few times.

YodaEmbedding avatar Nov 24 '19 05:11 YodaEmbedding

I don't use /? to "search", only to "navigate" to a specific thing, usually in the visible part of the buffer. For actually "searching" I generally use :g.

Anyway, what you ask for should be doable but I doubt I will have time to look into it before January.

romainl avatar Nov 24 '19 08:11 romainl

I'm a +1 on this. Thanks @romainl for showing consideration even though you personally find this nonsensical---uncommonly generous.

kevinlawler avatar Feb 12 '20 22:02 kevinlawler

+1, I use / only to search through document and I always keep them highlighted.

tmpm697 avatar May 15 '20 07:05 tmpm697

quick and dirty solution, for now change cool.vim as below:

function! s:PlayItCool(old, new)
    if a:old == 0 && a:new == 1
        " nohls --> hls
        "   set up coolness
        " noremap <silent> <Plug>(StopHL) :<C-U>nohlsearch<cr>
        " if !exists('*execute')
        "     noremap! <expr> <Plug>(StopHL) <SID>AuNohlsearch()
        " else
        "     noremap! <expr> <Plug>(StopHL) execute('nohlsearch')[-1]
        " endif

        " autocmd Cool CursorMoved * call <SID>StartHL()
        " autocmd Cool InsertEnter * call <SID>StopHL()
    elseif a:old == 1 && a:new == 0

tmpm697 avatar May 17 '20 11:05 tmpm697