incsearch.vim is dead. Long live incsearch

Demo of my patch

Last month, I opened a Pull Request to Vim which added incremental highlight feature — highlight all matches while incremental searching. One of most missing feature of Vim. And it’s merged today (Patch 8.0.1238)!

At the same time, I’m the author of the Vim plugin called incsearch.vim, which provides incremental highlight feature. It’s one of my favorite plugins I ever created and is beloved by lots of Vim users.

This post is story about “incsearch”. This is farewell to incsearch.vim.

incsearch.vim

It uses incsearch.vim

incsearch.vim is a Vim plugin which improve incremental searching. It provides functionality to highlight all matches while searching, to move cursor to next/previous match while searching and so on.

incsearch.vim is 3 years old. Here is the first commit on Aug 8, 2014. After the initial release, incsearch.vim has been incrementally improved and gained more and more users.

http://haya14busa.github.io/github-star-stats/#/haya14busa/incsearch.vim
Link

I talked about this plugin at VimConf 2014 short after the initial release. 
Here is the slide: /-improved
I remembered how excited I was to create this plugin and share it with lots of Vim users.

Improved search experience

I’m proud of incsearch.vim. It works like air. Users can replace default search commands with provided mappings and it just works same as default search command — with improved search experience like highlighting all matches and incremental cursor move feature.

It works like air, but behind the scene, there were countless efforts to make users feel “It just work like air”.

vital-over — command line interface library in Vim script

incsearch.vim emulates search command line interface in Vim script using vital-over, since we couldn’t extend default search command line to add rich feature. Creating CLI in Vim script and making it compatible with default Vim was really hard and crazy works ;)

@osyo-manga, who is famous for vim-over, is the author of vital-over. His work was really cool, incredible, and crazy enough to emulate CLI in Vim script… :) I still remember the development of vital-over. We had a lot of discussion about the interface of vital-over, looked into the default Vim behavior and improve it to be more compatible with default Vim. It was so fun to cooperate with him and make vital-over and incsearch.vim… I really respect his works.

Patch 8.0.1238 — highlight all matches while searching

link: Patch 8.0.1238

incsearch.vim is great… but why not implementing it in default Vim?

As described above, emulating search command line in Vim script is made by countless and crazy efforts… We did so good job to emulate most feature that users can use it like air, but we cannot emulate it perfectly after all.

Also, it’s useful feature for every Vim users :)

About one month ago, the number of GitHub stars of incsearch.vim reached 700 … and I revisited the fact. We should implement it in default Vim!

As for cursor moving feature while searching, Christian Brabandt already implemented <C-g> and <C-t> to move to the next/prev match with Patch 7.4.2259 (and 7.4.2268).

The problem is implementing highlighting feature. In fact, @itchyny sent a patch which highlight all matches while searching… about 3 years ago, a few month after the release of incsearch.vim. Sorry to kept all of you waiting for so long.. I should have written the patch earlier :)

itchyny’s original patch and discussion

So, I can start with itchyny’s patch. The patch already showed core logic to implement the feature. I investigated the source code and understood how it works after debugging a few hours… and I found the problem of itchyny’s patch which overrides last searched pattern even when cancelling search and fixed the problem. Also, added ‘inchlsearch’ option to turn on new feature, which was removed after some discussion. Tests are missing in the original patch too, so I wrote the tests by using new style test and :terminal feature for testing incremental search interactively .

Since, I’m not so familiar with C nor development of Vim and want feedback before sending the patch to vim-dev, I asked vim-jp to review my patch.

@k-takata kindly reviewed my patch and I can fix the coding-style problem. @ichizok gave me an idea to test the patch interactively by using ‘terminal’ feature. I also got some feedback from vim-jp members and after sending the patch to vim-dev, we discussed the patch with vim-dev members.

Unexpected new feature :) — CmdlineEnter and CmdlineLeave events

After some discussion, we reached the conclusion that we’ll turn on new highlighting feature when both ‘incsearch’ and ‘hlsearch’ are on. We would like to propose a way to turn on this feature for users who set nohlsearch, so Bram added new CmdlineEnter and CmdlineLeave events to control ‘hlsearch’ option. These new autocmd events are useful for other cases too!

is.vim — the successor of incsearch.vim

Now that default Vim can highlight all matches while searching, basic feature of incsearch.vim is provided by default. However, there are still some missing feature, so I created is.vim (‘is’ is short for ‘incsearch’) which is the successor of incsearch.vim.

It provides some functionality of incsearch.vim in default Vim.

  • Automatically clear highlight (:nohlsearch) after cursor is moved and some other autocmd event.
  • Incremental scroll to next match feature.

btw, is.vim uses new CmdlineLeave to implement the feature :)

is.vim — Automatic :nohlsearch
is.vim — Scroll to next match while searching

incsearch.vim is dead. Long live incsearch

is.vim provides some feature, but still incsearch.vim has unique feature like <Plug>(incsearch-stay) which doesn’t move cursor while searching and module functionality like fuzzy-search and migemo search modules.

However, maybe it’s time to say goodbye to incsearch.vim. Now, default Vim covers most use cases.

Farewell incsearch.vim. I’m very proud of you. You have been doing really great work so far.

Vim is “incrementally” being improved and your functionality will live in Vim itself in the future ;)

Long live incsearch.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.