Anbody does have an solution for a min lines number – in Codemirror?
min-height worked for me but do not insert empty lines for the height.
JS
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
gutter: true,
lineWrapping: true
});
CSS
.CodeMirror-scroll {
overflow: auto;
height: auto; overflow: visible;
position: relative;
outline: none;
min-height: 300px; /* the minimum height */
}
Maybe there is a simple solution to insert empty lines for that ?
remove the
min-height: 300px;and initialize the editor with new lines as the starting value:currently, CodeMirror’s
valueoption does not seem to have an affect for up to version 2.21. this can be easily bypassed by usingsetValue()after initialization:note:
make sure not to set
autoClearEmptyLines: trueas it will clash and cancel out the inserted empty lines.