benma / visual-regexp.el

A regexp/replace command for Emacs with interactive visual feedback
392 stars 28 forks source link

Query replace with non-regexp #45

Closed raxod502 closed 7 years ago

raxod502 commented 7 years ago

I really like the interface provided by vr/query-replace. Is it possible to have a non-regexp version of it, so that I can replace both query-replace-regexp and query-replace?

benma commented 7 years ago

It's definitely possible, but I am unsure about the interface. The cleanest fit might be to add it as another engine to visual-regexp-steroids so I don't have to add three new functions. Are you using the steroids package or would consider using it if this functionality ended up there?

raxod502 commented 7 years ago

I am using that package, yes. I was actually thinking that it might be best suited as another regex engine, but I wasn't quite able to figure out how to do it.

benma commented 7 years ago

@raxod502 sorry for the delay. I made a PR for this repo for a start: https://github.com/benma/visual-regexp.el/pull/46

Setting vr/plain to t should give you the desired functinality. Please test it out and let me know. The next step could be to add it as an engine to visual-regexp-steroids so one can more easily select it, resp. switch between regexp and non-regexp.

raxod502 commented 7 years ago

@benma I just tested the emacs-plain engine and it works great! Thanks so much! I will definitely be adding an easy way to use both modes in my own config.

benma commented 7 years ago

Great!

I merged this change and also added it as a new engine to visual-regexp-steroids: https://github.com/benma/visual-regexp-steroids.el/pull/22

You can use vr/select-replace etc. which prompts for which engine you want to use.

You might be interested in my own config which uses the prefix arg to select between the python and emacs engines:

https://github.com/benma/emacs.d/blob/master/modules/my-visual-regexp.el#L9

Maybe something like that could be useful to you.