Consider a simple file cdotest.txt
one two three
one two three
one two three
one two three
run a
:grep three cdotest.txt
then
:cdo s/three/four
:cdo s/three/Sthree
:cdo 2,$s/three/four
work well
while
:cdo 2,$s/three/Sthree or
:cdo 2,3s/three/Sthree
fail
one two three
one two SSSSthree
one two SSSSthree
one two SSSSthree
It looks like the bug occur only if you operate in a range prepend something to the matching pattern
Neovim has the same behaviour
The right output
vim 9.0
VoidLinux
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
This isn't a bug. :cdo runs a command on each quickfix entry. You have 4 quickfix entries.
Your first command :cdo s/three/four runs that substitution on each quickfix entry line. The range is not specified so it just runs on the line of the quickfix entry.
The later commands still run for each quickfix entry but you manually set the range to something else, so it runs 4 times on the range you have set.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Thanks,
but...
:cdo 2,$s/three/four replaces three with four from the second line to the end as expected?:cdo' the right command to perform such kind of replacement? can't :cdo` work in a range?—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
why :cdo 2,$s/three/four replaces three with four from the second line to the end as expected?
In this case, three no longer exists in the buffer, so the next 3 times it runs nothing happens because no three exists to substitute. In your surprise case, you substitution itself contains the expression you searched for, so it happens 3 more times three -> Sthree -> SSthree etc.
Hope that helps you :)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
this seems to be no issue, so let me close it
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Closed #13330 as not planned.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()