How to find out the keyword in ace-editor

353 views Asked by At

For ace-editor, I want to select one line and find out all the keywords within the line and output into the console. Which APIs from ace-editor that I can use for this purpose, and how to achieve the goal. Thanks.

1

There are 1 answers

0
a user On BEST ANSWER

you can use session.getTokens method like so

var row = editor.selection.getCursor().row
editor.session.getTokens(row).filter(function(t) {
    return t.type == "keyword"
})