With my Emacs (23.2) and without a user initialization file ( emacs -q), I found that it query-replaceworks just fine. This is my test.
I typed:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
I moved the cursor to the top of this text block
<f3> M-S-5 3 RET tj RET y y y q <f4>
who left me:
1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Pressing <f4>again left me with:
1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 tj 4 5
1 2 3 4 5
, . emacs -q, , , .