operand
operand

Reputation: 442

Any way to collapse marked text in Ace editor?

In Codemirror, they have a method called markText() described here: http://codemirror.net/doc/manual.html#api_marker

One of the options for that method allows you to collapse the marked text and replace it with something else. So, for example I can find all instances of "foo" and replace them with say, an underscore, but the internal value for the text remains "foo". And when a user deletes the underscore, the entire token "foo" is deleted, under the hood.

I'd like to switch to Ace for a simple IDE-like interface I'm building but I pretty much need this feature. (Unfortunately Codemirror has other issues which are making me look elsewhere)

Is there any way to achieve this in Ace?

Upvotes: 1

Views: 826

Answers (1)

a user
a user

Reputation: 24104

There is no builtin way of doing this yet. But there are two ways to implement it. If you need to replace only a few instances you could use folds (see session.addFold), but if you need to have many replacements and replacements are going to be inside a token, you can change values of highlighting tokens in session.bgTokenizer.lines. In any case you should create feature request for this at https://github.com/ajaxorg/ace/issues/new

Upvotes: 2

Related Questions