Change Height and Width of TextArea in codemirror

The CodeMirror user manual is your friend.

Example code:

<textarea id="myText" rows="4" cols="10"></textarea>

<script type="text/javascript" language="javascript">
    var myTextArea = document.getElementById('myText');
    var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
    myCodeMirror.setSize(500, 300);
</script>

myCodeMirror.setSize(null, 500);

You can pass null for either of them to indicate that that dimension should not be changed.

Documentation:

cm.setSize(width: number|string, height: number|string)

Programmatically set the size of the editor (overriding the applicable CSS rules). width and height can be either numbers (interpreted as pixels) or CSS units ("100%", for example). You can pass null for either of them to indicate that that dimension should not be changed.

Tags:

Javascript