Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggling on/off #36

Open
YodaEmbedding opened this issue Nov 23, 2019 · 11 comments
Open

Toggling on/off #36

YodaEmbedding opened this issue Nov 23, 2019 · 11 comments

Comments

@YodaEmbedding
Copy link

YodaEmbedding commented Nov 23, 2019

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
@romainl
Copy link
Owner

romainl commented Nov 23, 2019

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

@YodaEmbedding
Copy link
Author

YodaEmbedding commented Nov 24, 2019

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.

@romainl
Copy link
Owner

romainl commented Nov 24, 2019

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.

@kevinlawler
Copy link

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

@tmpm697
Copy link

tmpm697 commented May 15, 2020

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

@tmpm697
Copy link

tmpm697 commented May 17, 2020

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

@kevinlawler
Copy link

kevinlawler commented Jul 28, 2024

A hack to accomplish this is:

:set eventignore=CursorMoved,OptionSet,InsertEnter
" ...
:set eventignore=

For my case CursorMoved is enough. So the following fixes the vim-cool bug where highlighting is disabled when the cursor reaches the end of the buffer and wraps around.

nnoremap <silent> <leader>* :set eventignore=CursorMoved<CR>:execute("/blah")<CR>:set eventignore=<CR>

Using /blah, say with <expr>, instead of :execute("/blah") sidesteps these issues entirely.

@romainl
Copy link
Owner

romainl commented Jul 29, 2024

@kevinlawler I'm not sure what bug you are referring to. Could you provide a recording of it and a minimal reproducible test?

@kevinlawler
Copy link

kevinlawler commented Jul 29, 2024

Open vim

999iblah<return><esc>/blah<return>

highlighting disappears at top of file

This actually wrecks it for / and * and :execute versions - there may be more than one issue, verify on other real-world cases starting from the bottom with different positioning

This is as much time as I can provide currently

@romainl
Copy link
Owner

romainl commented Jul 29, 2024

Unfortunately I am unable to reproduce the problem, neither on your example nor on the couple of real world case I tried. I think I would have noticed it already given how often I use / in a given day.

@kevinlawler
Copy link

repros on latest macvim, neovim macos

 vim -u NONE -u /path/to/cool.vim

highlight-repro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants