title: How can I add a character at cursor?
body: <p>I'm trying to add a row of 'Hotkeys' to Code Mirror. For a normal <code>&lt;textarea id=code&gt;</code> I could do: 
  <code>insertAtCursor(code,'hello')</code>
  With:</p>
  
  <pre><code>function insertAtCursor(textArea,text) 
  {
      if (textArea.setSelectionRange)
      {
          textArea.value = textArea.value.substring(0,textArea.selectionStart) + text + textArea.value.substring(textArea.selectionStart,textArea.selectionEnd) + textArea.value.substring(textArea.selectionEnd,textArea.value.length);
      } 
      else if (document.selection &amp;&amp; document.selection.createRange) 
      {
          textArea.focus();
          var range = document.selection.createRange();
  
          range.text = text + range.text;
      }
  }
  </code></pre>
  
  <p>How could I do this with a CodeMirror instance?</p>