I’ve used `C-s` and `C-r` to search in Emacs for ages. One of the most used combos was to move somewhere, start incremenental search, and yank some words from the current position in the buffer: `M-b M-b C-s C-w C-w C-s`. Now I’m trying to give Swiper a fair try. I’ve been using Yvy Mode until now but I never went all the way.
Recently, however, I stumbled upon the Swiper repository, which comes with a README that has a sample rebinding of keys for all the Ivy, Counsel and Swiper stuff. One of them was to use `C-s` for `swiper-isearch` instead of `isearch-forward`. OK! I’m going to try it.
Note that `swiper-isearch` is not line-based like `swiper` is. That is, `<down>` goes to the next match, even if the next match is on the same line.
But… my fingers are all confused, now. I need to switch modifier keys: `M-b M-b C-s M-j M-j <down>`. Perhaps I should start using `M-s` instead. But then again, that prefix hides a ton of functionality. But then *again*, I never use it.
This is what *Emacs Paralysis* looks like, I’m telling you!
Anyway, once you started your search for the current word using `C-s M-j` you can use `C-c C-o` to switch to Yvy Occur mode. From there, you can use `w` or `C-c C-p` to switch to Wgrep mode, which allows you to make changes to the buffer and to write them back to the files using `C-x C-s`. Strangely enough this doesn’t work if you’re using it in a buffer that has no file associated with it! How strange. This must be an unintended consequence of the grep heritage.
In any case, I’m still trying to get used to this. And I’ll give `iedit` a try as well. I’m hoping for some sort of refactoring support in Emacs.
All of these idea are from @takeonrules’s blog post:
Why I Chose Emacs as My New Text Editor
#Emacs