I'm new here. And I am developing an addin for MM. I'm interested how I can set the current line of the active document. I only find GetCurrentLine(). Is there a way to set the current line. I know I can do by operating the whole document string,but when the document is large,it might bring some performance issue.
Take a look at the Model.MarkdownEditor.AceEditor
object which has a bunch of methods for manipulating the editor. Amongst them is a GotoLine()
method. On top of that you can use AceEditor.Invoke()
to directly call editor JavaScript methods in the editor.js
- there are a bunch more that are not exposed in the AceEditor object.
GotoLine()
will set the insertion point/cursor for the editor. Once you're at the desired location you can use Model.MarkdownEditor.SetSelection()
to insert text into the document.
Actually looking at what's on the MarkdownDocumentEditor, the editor has both GotoLine()
and SetSelection()
methods directly. So you can do:
var editor = Model.ActiveEditor;
editor.GotoLine(100);
editor.SetSelection("Way to go!\n\n");
Hope this helps,
+++ Rick ---