yes as @boocs stated
you need to await
both textEditor.edit()
and replaceText()
you don't need to refresh textEditor
between each replaceText()
call
however you do need to refresh textEditor
between each DoIt()
call
as currently you're only getting the activeTextEditor
when starting the extension
so it wont work when switching documents