I am working on customizing the codemirror for my new language mode. As part of this new mode implementation, I am writing a new tool bar where user can select some text and
Here's how I did it:
function insertTextAtCursor(editor, text) { var doc = editor.getDoc(); var cursor = doc.getCursor(); doc.replaceRange(text, cursor); }