title: VSCode extension - how to alter file's text
body: <p>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? </p>
  
  <pre class="lang-ts prettyprint-override"><code>// this method is called when your extension is activated
  // your extension is activated the very first time the command is executed
  export function activate(context: vscode.ExtensionContext) {
  
    // Use the console to output diagnostic information (console.log) and errors (console.error)
    // This line of code will only be executed once when your extension is activated
    console.log('Congratulations, your extension "myExtension" is now active!');
    console.log(process.versions);
  
    // The command has been defined in the package.json file
    // Now provide the implementation of the command with  registerCommand
    // The commandId parameter must match the command field in package.json
    let disposable = vscode.commands.registerCommand('extension.myExtension', () =&gt; {
      // The code you place here will be executed every time your command is executed
  
      let activeEditor = vscode.window.activeTextEditor;
      if (!activeEditor) {
        return;
      }
      let text = activeEditor.document.getText();
  
      getAsyncApi(text).then((textToInsertIntoDoc) =&gt; {
  
        let finaldoc = insertTextIntoDoc(text, textToInsertIntoDoc);
  
        // not what I want - just used to see new text
        vscode.window.showInformationMessage(textToInsertIntoDoc);
      });
  
    });
  
    context.subscriptions.push(disposable);
  }
  </code></pre>