最佳答案
迭代所有行并检查indexOf
function findFooLineNumbers(editor,foo) {
var lines = editor.session.doc.getAllLines()
var fooLineNumbers = []
for (var i = 0,l = lines.length; i < l; i++) {
if (lines[i].indexOf(foo) != -1)
fooLineNumbers.push(i)
}
return fooLineNumbers
}