Swiper-isearch - a more isearch-like swiper07 Apr 2019
Since its introduction in 2015, swiper, while nice most of the time, had two problems:
- Slow startup for large buffers.
- Candidates were lines, so if you had two or more matches on the same line, the first one was selected.
Over time, workarounds were added to address these problems.
Problem 1: slow startup
Almost right away, calling
font-lock-ensure was limited to only small enough buffers.
counsel-grep-or-swiper was introduced. It
uses an external process (
grep) to search through large files.
(setq counsel-grep-base-command "rg -i -M 120 --no-heading --line-number --color never %s %s")
The advantage here is that the search can be performed on very large files. The trade-off is that we have to type in at least 3 characters before we send it to the external process. Otherwise, when the process returns a lot of results, Emacs will lag while receiving all that output.
Problem 2: candidates are lines
Finally, less than a week ago, I wrote
swiper-isearch to fix #1931.
Differences from the previous commands:
Every candidate is a point position and not a line. The UX of going from one candidate to the next is finally
isearch-like, I enjoy it a lot.
swiper, no line numbers are added to the candidates. This allows it to be as fast as anzu.
counsel-grep, no external process is used. So you get feedback even after inputting a single char.
I like it a lot so far, enough to make it my default search:
(global-set-key (kbd "C-s") 'swiper-isearch)
swiper-isearch, see if it can replace
swiper for you;
counsel-grep-or-swiper still has
its place, I think. Happy hacking!
PPS. Thanks to everyone who contributes issues and patches!