Search code examples
javacssjspcodemirror

How to set text align and indentation in codemirror editor as it always start in the middle?


I have problems using CodeMirror. When I typed my codes in the textarea, it will start in the middle and not at the most left even after going to next line. Must I modify the CSS?

JSP:

<script>
var editor = CodeMirror.fromTextArea(document.getElementById("myTextArea"), {
mode:"javascript",
lineNumbers: true,
autofocus: true
});
editor.setSize(500,680);
</script>

https://i.sstatic.net/wvhVZ.jpg


Solution

  • You can add a CSS rule like .CodeMirror { text-align: left!important; } to override this.