zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.95k stars 1.17k forks source link

Mode for literal search #3177

Closed dustdfg closed 6 months ago

dustdfg commented 6 months ago

Description of the problem or steps to reproduce

When I select text and press Ctrl+f, it automatically opens search in the infowindow and inserts selected text there. But it treat it like a regex.... If for example I selected my_func() to see where this function is called without arguments I will get a regex with empty group () so I will get all the places where the function is called (also counting places where it is called with arguments) or even if I just use it for assigning a variable/lambda like var a = my_func.

In general I could rewrite this issue as I need a literal search mode like in the replace(all) commands

Specifications

Commit hash: current master OS: Debian 12/testing Terminal: foot

dustdfg commented 6 months ago

Or as partial solution when user selects text text and presses ctrl+f it is possible to automatically add \ where is needed...

dmaluka commented 6 months ago

You can already do literal search, by using Alt-Shift-f instead of Ctrl-f. Or you can bind Ctrl-f to FindLiteral instead of the default Find.

But yeah, it makes sense to automatically escape the selected text in the case of regex search, so that it does the right thing in all cases. Fixed in https://github.com/zyedidia/micro/commit/399134fe5b38e9d0e5a1512f841b4147256cc950.