如何在ace-editor中找出关键字
How to find out the keyword in ace-editor
对于ace-editor,我想select一行,找出该行内的所有关键字并输出到控制台。我可以将 ace-editor 中的哪些 API 用于此目的,以及如何实现该目标。谢谢。
你可以像这样使用session.getTokens
方法
var row = editor.selection.getCursor().row
editor.session.getTokens(row).filter(function(t) {
return t.type == "keyword"
})
对于ace-editor,我想select一行,找出该行内的所有关键字并输出到控制台。我可以将 ace-editor 中的哪些 API 用于此目的,以及如何实现该目标。谢谢。
你可以像这样使用session.getTokens
方法
var row = editor.selection.getCursor().row
editor.session.getTokens(row).filter(function(t) {
return t.type == "keyword"
})