Format code while typing using JavaScript

If you want to format the code while typing, you can use CodeMirror:

<!DOCTYPE html>
  <meta charset = 'utf-8'>
  <title>Edit code while typing</title>
  <script src = ''></script>
  <script src = ''></script>
  <link rel = 'stylesheet' href = ''>
  <link rel = 'stylesheet' href = ''>
    <textarea id = 'editor' autofocus = 'true'></textarea>
    var editor = CodeMirror.fromTextArea(document.getElementById('editor'), {
        theme: 'monokai',
        mode: 'javascript',
        lineNumbers: true

Here you have a skeleton using the Monokai theme.

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.