I am trying to get value on single line on Ace editor.
According to Ace Editor documentation:
gotoLine()
to navigate to single linegetLine()
to get single linegetLines()
to get multiple linesHere is what I tried:
var html = ace.edit("html");
html.getSession().setMode("ace/mode/html");
html.setTheme("ace/theme/eclipse");
html.setPrintMarginColumn(false);
html.resize();
var line4 = html.gotoLine(4);
var getfour = html.getLine(4);
var getfoureight = html.getLines(4,8);
gotoLine()
works. getLine()
and getLines()
doesn't work.
What am I doing wrong?
getLine
and getLines
are functions on the session, so you need to call them like
var editor = ace.edit("html");
editor.setValue("line0 \n line1 \n line2 \n line3")
editor.session.getLine(2) // returns " line2 "
editor.session.getLines(1, 2) // returns [" line1 ", " line2 "]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With