micro
micro copied to clipboard
replace doesn't allow regex
Description of the problem or steps to reproduce
Say I want to replace 4 spaces with a tab:
- Type
CtrlE
to get the command window - Type
replace ' ' '\t'
That would replace 4 spaces with the \t
literal rather than a tab character
Specifications
Version: 2.0.4 Commit hash: c5b0c2d OS: Linux 5.6.13-arch1-1 Terminal: Fish
I’ll look into fixing this. In the meantime I recommend using the > retab
command (along with the appropriate tabstospaces
value you want) to achieve what you want.
thanks
Note this issue isn't really about regex, but ANSI C Escape Sequences, of which \t
, \n
, and \\
are really common. These can be expanded e.g. in a Bash shell with e.g. printf $'here are 2 tabs "\t\t" and a newline\n'
.
It looks like it might be enough to pass the replacement string through fmt.Sprintf to interpret the codes, but maybe this would complicate the selection boundaries after replacement.