CodeMirror 3 Indent All Lines / Autoformat

Problem You have created an instance of a CodeMirror and initialized it with some text and would like to correct its indentation or you would like to give the user the option to 'autoformat' the text entered. Solution Iterate over all lines in the editor and indent them individually: var e = CodeMirror.fromTextArea(textarea.get(0), {}); for … Continue reading CodeMirror 3 Indent All Lines / Autoformat