this post was submitted on 11 Nov 2023
12 points (100.0% liked)

Emacs

2190 readers
1 users here now

Our infinitely powerful editor.

founded 4 years ago
MODERATORS
 

Why does replace-regexp backwards work so differently?

C-u - M-x replace-regexp \w+

The - prefix arg replaces backwards but it hits one char at a time, as if the plus sign weren't there. The same replacement forwards (without the prefix arg) does hit one word at a time. What's going on, @[email protected]?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 11 months ago

Yes, I got that, that wasn't the weird part. The weird part is why the matcher is searching char-by-char backwards in the first place as opposed to skipping match-by-match.

I'll use "\b\w+", that seems to work well. \W\w+ was not good since it caught the spaces.

(Thanks for your patient repeated replies, BTW, I don't mean to come across as ungrateful.)

@0v0 @emacs