helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
34.09k stars 2.52k forks source link

Global search and replace #4335

Open CBenoit opened 2 years ago

CBenoit commented 2 years ago

Add some form of support for global search-and-replace.

Discussed in https://github.com/helix-editor/helix/discussions/3793

Originally posted by **nour-dev** September 11, 2022 hey, the question is the title. I know how to make per file search and replace. what I want to do is to search + replace in the entire workspace files (or sub of them by ext or some sort of regex). for example when I want to search `'test'` I do: - click `space+/`. - the search picker show list of files contain the regex. then when I want to replace it I need to go to each file and replace manually. so there is not way to replace them all with one or more commands. is there any hack to do this ? or I need to use external shell tools like `sed` or `sd` ? thanks.
Teiolass commented 2 years ago

How should this behaviour interact with the undo? Add the change only to the alread open buffers?

I think this solution is quite dirty, but it is the best that comes to my mind. I think that letting this feature to be handled by external programs would be a better choice.

helmesjo commented 2 years ago

One approach I've seen before is a prompt where you'd say if to open all files when replacing (adding to undo buffer) or replace without opening (no undo). The prompt can be handled in many other ways of course, just that it's an explicit choice. Personally I'd say this is an expected feature in any IDE, so I vote yay. (:

QiBaobin commented 2 years ago

Open a buffer for the result, any changes on that buffer would effect related files? This can undo, something like https://github.com/mhayashi1120/Emacs-wgrep

CBenoit commented 2 years ago

4381 sounds exactly like this 🙂

wongjiahau commented 1 year ago

What we need is something like Vim’s cdo command, which allows user to apply Ex command to every entry in the quickfix list.

My suggestion, add a simple command call run-macro-on-last-picker.

pascalkuthe commented 1 year ago

The plan is very much something like https://github.com/helix-editor/helix/pull/4381 that would leverage helixes existing multi-cursor support. That PR just needs a better PR and for that larger changes are likely needed