How to add new line programmatically in CodeMirror? -


i need insert new line next current line number in codemirror.

i viewed documentation didn't find appending content @ end of line.

please help. :(

get current line cursor position, , act on it. should (not tested):

var doc = cm.getdoc(); var cursor = doc.getcursor(); // gets line number in cursor position var line = doc.getline(cursor.line); // line contents var pos = { // create new object avoid mutation of original selection     line: cursor.line,     ch: line.length - 1 // set character position end of line } doc.replacerange('my new line of code\n', pos); // adds new line 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -