title: Get started with the formatting in Monaco Editor
body: <p>I am trying to add a formatting to a custom language in Monaco Editor. It seems that we could use <a href="https://microsoft.github.io/monaco-editor/api/modules/monaco.languages.html#registerdocumentformattingeditprovider" rel="nofollow noreferrer">monaco.languages.registerDocumentFormattingEditProvider</a>. </p>
  
  <p>As an example, I have made a working <a href="https://plnkr.co/edit/a151xgFBr5ffxdJGV5Pd?p=preview" rel="nofollow noreferrer">plunker</a>. Now I want to add a very simple formatting rule to the whole document: <strong>add one newline after each error log</strong>. But I don't know how to write the provider in <code>mySpecialLanguage.js</code>:</p>
  
  <pre><code>monaco.languages.registerDocumentFormattingEditProvider('mySpecialLanguage', {
    provideDocumentFormattingEdits: function (model, options, token) {
      console.log("here") // which is well printed
      // should return a value of type TextEdit[], but I don't know how to construct one
    }
  })
  </code></pre>
  
  <p><code>provideDocumentFormattingEdits</code> should return a value of type <code>TextEdit[]</code>, where <code>TextEdit</code> is specified <a href="https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.textedit.html" rel="nofollow noreferrer">here</a>.
  However, I cannot find enough code samples of constructing <code>TextEdit</code> in Monaco Editor (there are some examples for VSCode). Could anyone point me to some samples and help me get started?</p>