VSCode extension - how to alter file's text

后端 未结 4 1720
天涯浪人
天涯浪人 2021-02-20 12:56

I have an extension that grabs the open file\'s text and alters it. Once the text is altered, how do I put it back into the file that is displayed in VSCode?



        
4条回答
  •  一整个雨季
    2021-02-20 13:27

    Here is the code snippet that will solve your issue :

    activeEditor.edit((selectedText) => {
        selectedText.replace(activeEditor.selection, newText);
    })
    

提交回复
热议问题