Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.
/ vim-chimera Public archive

Clear search matches automatically in vim and neovim

License

Notifications You must be signed in to change notification settings

Chromosore/vim-chimera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

vim-chimera

See the note at the end of the § Hybrid Approach

vim-chimera clears the search matches ('hlsearch') when you're not searching.

I know there are several existing plugins that solve this very problem1, but none of them solved this problem the way I wanted, so I've made a new one!

I've named this plugin vim-chimera because then approach to choose when to clear matches is a hybrid between the vim-cool way and the is.vim way.

Installation and version

Install this plugin however you want.

It needs a decently recent version of vim to work (in other words: I have no idea of the version requirement) and supports neovim as well.

Hybrid approach

vim-cool clears matches when the cursor moves. But, to check if the move wasn't due to a command like n, it also checks if the new position of the cursor is a search match.

The downside of this approach is that it sometimes keeps matches highlighted after you've moved, because landed on a match by accident. For instance, this happens if you have vertically aligned matching items and you press j.

is.vim on the other hand uses mappings to schedule autocommands that clear the matches when the cursor is moved. For instance, when n is pressed, it removes all scheduled autocommands and schedules a new one one to clear the matches after a cursor move.

This approach is great because it is reliable (e.g. it won't keep the matches highlighted when you don't want to) but its user-triggered model is less great, because matches won't be removed in situations outside of the provided mappings (such as using :s).

That's why I created this plugin. It uses a hybrid approach because it relies on both autocommands and mappings. That is, it clears matches when the cursor is moved - without checking the new position of the cursor - unless the cursor move was initiated by one of the search commands.

EDIT before archiving: My hybrid approach was actually not a silver bullet or a magic remedy. It had its own flaws. I could've fixed it but I did not do it and now that I don't use it anymore I don't want anyone to be fooled by this promising bafflegab.


This plugin is licensed under the MPL-2.0. See LICENSE.txt.

Footnotes

  1. is.vim, vim-cool, vim-slash, vim-evanesco

About

Clear search matches automatically in vim and neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published