evil icon indicating copy to clipboard operation
evil copied to clipboard

substitution-count backreference (\#) doesn't work with evil-ex substitute

Open mohkale opened this issue 4 years ago • 0 comments

Issue type

So I've been looking into some of the builtin emacs regexp replace syntax specifics and alongside the ability to perform lisp evaluations inside of substitutions (eg. %s/foo/\,(upcase \0)/g replaces all occurences of foo with FOO) there's also the \# backreference which counts the number of substitutions performed so far. However emacs evil-ex-substitution doesn't seem to support this.

  • [X] Enhancement request

Environment

Emacs version: ``GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3) of 2020-08-28 Operating System: Arch Linux Evil version: Evil version evil-git-fa8cf29 Evil installation type: Straight Graphical/Terminal: Terminal

Reproduction steps

For example if I have a buffer like this and I run :%s/\(.+\):/\#. /g.

0:foo
0:bar
0:baz
0:bag
0:bam
0:boom
0:bam

Expected behavior

0. foo
1. bar
2. baz
3. bag
4. bam
5. boom
6. bam

Actual behavior

My guess is that evil is resetting the substitution count every time it substitutes a single match.

0. foo
0. bar
0. baz
0. bag
0. bam
0. boom
0. bam

Further notes

You can compare the expected with actual behaviour by running M-x query-replace-regexp.

mohkale avatar Jan 28 '21 01:01 mohkale