Man, this is fast, I really appreciate your help.
I tried both macro and they all ran fine in my simple example.
The 1st 'not secure' macro:
(1) You mentioned that the 'not secure' macro may run into problem that the end position may not be restored correctly after replace, could you give an example to show?
(2) there are several 'key HOME' there, do they bring the cursor back to the start position of the CURRENT line, or the start position of the SELECTED TEXT? I don't quite understand why you have to put 'key HOME' there?
The 2nd macro:
(1) If I understand correctly, the 'Top' is put to resolve the issue of 'key HOME' in the 1st macro, and you mentioned that since 'Replace All' does not change the cursor position, hence only 1 'Top' after 'Paste' is enough. But then, 'Replace All' is also used in the 1st macro too, why then 4 'Key HOME' are needed there?
This is very helpful, thanks a lot.
BTW, just checked with IT, my company has corporate lisense with Uedit, which is very good to me. Thanks again, looking forward to hearing from you soon.