Ace editor set text selection
Asked Answered
T

1

5

My text is:

My favourite singer is {Bruce Springsteen} and he was born in New Jersey.

I want to programmatically select the text between the curly braces including them. I cannot find a straightforward way.

Toms answered 17/10, 2014 at 15:37 Comment(0)
T
10

you can do editor.find("{Bruce Springsteen}") or

var Range = require("ace/range").Range;
editor.selection.setRange(new Range(0, 23, 0, 42));
// use .setRange(.., true) for setting cursor at the beginning of the selection
Trinity answered 17/10, 2014 at 16:7 Comment(2)
I found out I had to write: var Range = ace.require("ace/range").RangeToms
if you don't want to dirty your code with filthy requires, it seems new ace.Range(0, 23, 0, 42) works fine.Osmond

© 2022 - 2024 — McMap. All rights reserved.