zyedidia / micro

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

replace is inconsistent with find and useless for large files #1732

Open HJarausch opened 4 years ago

HJarausch commented 4 years ago

Version 2.04

OS: Termux Terminal: Termux 1) backslashes have to be doubled (in a regexl contrary to the find command 2) independent of the cursor position, replace always starts at the first line of the file. Using it on a file of several thousands of lines is impractical therefore

zyedidia commented 4 years ago

Micro uses the same rules as the shell to parse command bar arguments. This causes the annoying problem that backslashes have to be doubled to be escaped once as a command argument and then again for when they are passed into the regexp engine. One solution is to use single quotes instead of double quotes which causes literal parsing at the shell level. So you can use > replace '\\' backslash to replace all \ characters with backslash.

Regarding point 2, this was just reported and fixed in #1731. Also note that if you make a selection, search and replace will only happen in the selected region.