Sublime Forum

Search in a specific context

#1

Is it possible to search only in a specific context, or to exclude matches that are present in a specific context? For example, can I search for foo while excluding any foo that is found in comments?

0 Likes

#2

Sublime’s search is purely text based, so apart from perhaps some regex shenanigans to make sure that // doesn’t appear somewhere before the text you’re looking for, I would imagine that you would need a package with deeper knowledge of the code to do such searches for you.

1 Like

#3

@OdatNurd, thank you. That makes sense.

If someone is aware of a package, please let me know.

0 Likes

#4

for a single file I just do a select by scope - comment then search in selection.

1 Like

#5

Hi @kingkeith, can you please clarify what you mean by select by scope? Are you talking about expand selection to scope? I don’t see any options to insert - comment.

0 Likes

#6

Console …

view.sel().add_all(view.find_by_selector("- comment"))

… that’s what API heros do. :test_tube:

3 Likes