Coder Social home page Coder Social logo

auto nohlsearch about vim HOT 9 CLOSED

habamax avatar habamax commented on July 24, 2024 1
auto nohlsearch

from vim.

Comments (9)

romainl avatar romainl commented on July 24, 2024 6

(mostly for Neovim compatability)

Sigh…

from vim.

romainl avatar romainl commented on July 24, 2024 1

The doc is riddled with "hackish" examples like this so why not one more? I find the idea of adding a small plugin better, though. MacVim releases are lagging a bit so I didn't have a chance to play with your commenting plugin yet but it definitely looks like the way to go.

FWIW, vim-cool was a pretty successful attempt to solve one of my pet peeves with hlsearch: that it lingers on after it stopped being relevant. Whether it is through a built-in plugin, a snippet in the doc, a third-party plugin, or in the core, the problem can be considered solved at this point and, as such, doesn't deserve much attention.

But that still leaves the other one: that the highlighting affects all windows, for which there is no workaround AFAIK. If some effort can be made to improve hlsearch, I think that's where it would be most useful.

from vim.

chrisbra avatar chrisbra commented on July 24, 2024 1

There is an entry in todo.txt to make 'hlsearch' global/local option. I remember I spent some time several years ago looking into it (but at least back then it wasn't that simple, but I forgot details).

Regarding @habamax request, does it make sense to add this (and possibly also the highlight-yank implementation from the help page) into the vim-scripts library. Not sure if we would be littering the library and if this is a particular good idea or rather a bad one 🤷

from vim.

habamax avatar habamax commented on July 24, 2024

I am not sure about library (don't know the purpose of it) but having packadd autonohlsearch should be easy enough to use.

from vim.

chrisbra avatar chrisbra commented on July 24, 2024

alright then can you make this a real PR then please? Please don't forget a bit of documentation and also please leave adjusting 'updatetime' option value alone.

from vim.

girishji avatar girishji commented on July 24, 2024

I have something similar in my config, but I prefer 10 sec delay, and also have <esc> do nohls in addition. Maybe you can make the timeout configurable by using autocmd CursorHold * timer_start(timeout - &ut, (_) => feedkeys("\<plug>(nohlsearch)", 'm')).
I also prefer keeping highlights in insert mode as I replace some highlighted fragments (for instance).

from vim.

benknoble avatar benknoble commented on July 24, 2024

One other note: if hlsearch is made global/local, I’d prefer the default to stay as is (it’s remarkably useful when looking at commit diffs + an open buffer to quickly highlight long function names in all windows, for example).

from vim.

habamax avatar habamax commented on July 24, 2024

Maybe you can make the timeout configurable by using autocmd CursorHold * timer_start(timeout - &ut, (_) => feedkeys("\<plug>(nohlsearch)", 'm')).

Wouldn't it trigger if after updatetime but before additional timeout there would be cursor movement? And what if at that time I will search for another thing? Say if there is 6 seconds of additional timeout, I theoretically can do another search which would be "unhighlighted" almost right away. Not sure though.

from vim.

girishji avatar girishji commented on July 24, 2024

Wouldn't it trigger if after updatetime but before additional timeout there would be cursor movement? And what if at that time I will search for another thing? Say if there is 6 seconds of additional timeout, I theoretically can do another search which would be "unhighlighted" almost right away. Not sure though.

Correct, there is no good solution. Although I set updatetime to 10 seconds in my profile, it has an undesired effect: the swap file is not written soon enough. Ideally, there should be an independent hlsearchtimeout variable implemented in the core.

from vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.