You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置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 both Function and Method keywords (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 for Do.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 and End Function using 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 as Do.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/Method line to the corresponding End 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:50:28