How to get a reference to a CodeMirror instance

If you want to access a CodeMirror instance, perhaps because it was created programmatically, or by a module you don’t control, you can access it like this: //Get a reference to the CodeMirror editor var editor = $(‘.CodeMirror’)[0].CodeMirror; //You can then use it as you wish editor.setValue(‘lorem ipsum yada yada’); editor.replaceSelection(‘this is a test’); In […]