Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Embed ace editor with arbitrary line number start

Tags:

ace-editor

I'd like to embed code snippets into a page with Ace Editor as demonstrated here.

However since these snippets are to be drawn from a larger file, I'd like the line numbers in the gutter to reflect the original line number of the code. In other words I'd like to be able to specify for an embedded instance, what number it should assign to the first line and count from.

Can Ace Editor be configured (or hacked) to behave in this way?

like image 724
Nat Avatar asked Jul 27 '13 13:07

Nat


1 Answers

easily, call

editor.setOption("firstLineNumber", 10)
// this is same as editor.session.setOption(...)

see https://github.com/ajaxorg/ace/blob/16b542aea/lib/ace/editor.js#L2681

like image 169
a user Avatar answered Sep 19 '22 11:09

a user