SavvasM
SavvasM

Reputation: 49

Ace editor set value at current line

I have an issue with the Ace editor. Whenever I insert a value via editor.setValue(val) it gets inserted at the bottom of the document. Is there any way to insert the value at the current line?

Thanks

Upvotes: 0

Views: 1382

Answers (1)

a user
a user

Reputation: 24104

to insert a line use

editor.session.insert({row: 1, column: 0}, "text\n")

and to replace a line use

var Range = require("ace/range").Range // ace.require in no-conflict mode
editor.session.replace(new Range(1, 0, 1, Number.MAX_VALUE), "text")

or

editor.session.replace({
    start: {row: 1, column: 0},
    end: {row: 1, column: Number.MAX_VALUE}
}, "text")

Upvotes: 2

Related Questions