In visual selection mode, accessed with ctrl-v
, I can replace the character I want (say Z to be replaced by A) within my selection by typing :
followed by s/Z/A
.
This is extremely useful.
Here is a case where it works:
12_0test
12_1test
12_2test
12_3test
12_4test
12_5test
...
I select the "2" in the "12" (ctrl-v
and use arrow keys to select all rows with 2 which results in a column of 2 being highlighted) and do :
followed by s/2/3
. I get what I'm expecting:
13_0test
13_1test
13_2test
13_3test
13_4test
13_5test
...
But I just came across a case where, when in a series of lines the first two characters are the same (here 11), block selecting the 2nd digit and trying to replace it with another digit will replace the 1st digit.
Here is what I mean.
11_0test
11_1test
11_2test
11_3test
11_4test
11_5test
...
I select the column of the second "1" in the "11", then :
followed by s/1/2
; but I end up with this undesired output:
21_0test
21_1test
21_2test
21_3test
21_4test
21_5test
...
Why is it so?