2

Notepad++ has a Function List feature that allows for quick jumping to functions. This is all fine and dandy, but I find that if I'm working in JavaScript and use anonymous functions, then it quickly becomes very silly; my current file has almost 100 instances of "function" in the list!

I know that it has a filter, but that only allows you to search for a specific function. Is there a way I can filter out anonymous functions (or any function names in general)?

1 Answer 1

4

You can modify the regular expression that finds the functions (see Notepad++ help).

Find the js_function parser and change the first nameExpr inside the functionName element from

"[_A-Za-z][\w_]*[\s]*[=:]|[_A-Za-z]?[\w_]*[\s]*\("

to

"[_A-Za-z][\w_]*[\s]*[=:]|(?<=function )[_A-Za-z]?[\w_]*[\s]*\("

This adds a lookbehind to the expression, ensuring that the word "function " (including a space) precedes the function name. If it doesn't, it's an anonymous function and will not show up in the function list.

3
  • 1
    Excellent! David Blanchard's answer worked like a charm. BTW - the file that David is referring to is functionList.XML and is found in: C:\Users\<USER NAME>\AppData\Roaming\notepad++
    – user397728
    Dec 10, 2014 at 17:01
  • Oh wow, I didn't even see this answer. Thanks, it works great!
    – Schism
    Aug 23, 2015 at 13:50
  • Now, the suggested trick does not work anymore because npp does not support look behind operations (see the Notes on regular expressions for parsers in npp-user-manual.org/docs/function-list/…)
    – beaver
    Jan 6, 2022 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.