Olalekan
Olalekan

Reputation: 475

Ace Editor get value on single line

I am trying to get value on single line on Ace editor.

According to Ace Editor documentation:

Here 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?

Upvotes: 9

Views: 4050

Answers (1)

a user
a user

Reputation: 24104

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 "]

Upvotes: 11

Related Questions