如何配置VS Code funcList插件正则,适配含特殊字符的自定义语言
Fixing FuncList Regex for Custom Language with Dot-Included Function Names
Let's tackle your FuncList regex issue step by step. The core problems with your original config were twofold: the \w+ pattern couldn't match function names containing dots (like Do.Something), and your nativeFilter wasn't set up to capture the entire function block from start to end.
Here's the updated settings.json that addresses both issues:
{ "funcList.nativeFilter": "/^(?:Function|Method)\\s+[\\w.]+\\([^)]*\\)[\\s\\S]*?End\\s+Function$/mg", "funcList.displayFilter": "/^(?:Function|Method)\\s+([\\w.]+)\\(([^)]*)\\)/$1($2)", "funcList.sortList": 1, "funcList.doubleSpacing": false }
Breakdown of the Changes:
1. funcList.nativeFilter
^(?:Function|Method): Matches the start of a function definition line, accounting for bothFunctionandMethodkeywords (using a non-capturing group since nativeFilter doesn't support groups for extraction).\\s+: Matches one or more spaces between the keyword and the function name.[\\w.]+: Replaces your original\\w+to match function names that include letters, numbers, underscores, and dots (exactly what you need forDo.Something).\\([^)]*\\): Captures the entire parameter list inside the parentheses (works for simple parameter lists without nested parentheses).[\\s\\S]*?: Matches all content between the function definition line andEnd Functionusing a non-greedy pattern (this ensures we don't accidentally capture multiple functions in one go).End\\s+Function$: Matches the end of the function block, anchored to the end of the line./mg: Enables multi-line mode (so^and$match line starts/ends) and global mode (to find all functions in the file).
2. funcList.displayFilter
- This regex uses two capturing groups to extract exactly what you want for the function list display:
([\\w.]+): Captures the full function name (including dots).([^)]*): Captures the parameter list.
- The replacement pattern
/$1($2)combines these groups to display the function asDo.Something(paramOne, paramTwo), just like you wanted.
Testing with Your Code Snippet
For your sample code:
Function Do.Something(paramOne, paramTwo) '... End Function Method Do.Something_Else(paramOne, paramTwo) '... End Function
- The nativeFilter will correctly capture each full function block from the
Function/Methodline to the correspondingEnd Function. - The displayFilter will show:
Do.Something(paramOne, paramTwo)Do.Something_Else(paramOne, paramTwo)
Optional Adjustment
If your function definitions might have trailing spaces before the end of the line, modify the nativeFilter's closing pattern to End\\s+Function\\s*$ to ignore any extra whitespace.
内容的提问来源于stack exchange,提问作者SuperVeetz
相关产品推荐
相关产品推荐

