【问题标题】:How to write Vim foldexpr for xdebug trace files with memdeltas如何使用 memdeltas 为 xdebug 跟踪文件编写 Vim foldexpr
【发布时间】:2010-10-05 14:54:04
【问题描述】:

我对 Vim 表达式一无所知。我有一个 vim foldexpr,它带有一个用于 xdebug 跟踪文件的语法文件。现有表达式如下所示:

foldexpr=strlen(substitute(substitute(substitute(substitute(getline(v:lnum),'^TR.*$','',''),'\\s>=>','->',\"g\"),'^\\s.\\{20\\}\\(\\s\\+\\)\\?->.*$','\\1',''),'\\s\\s','\',\"g\"))-2

这对于默认跟踪文件来说可以正常工作,如下所示:

0.0974    3908596     -> GenericDispatcher->dispatch() /home/tomw/source/public_html/main.php:49
0.0975    3908676       -> ReflectionClass->getMethods() /home/tomw/source/presentation/framework/routing/GenericDispatcher.php:59
0.0975    3910532       -> ReflectionFunctionAbstract->getName() /home/tomw/source/presentation/framework/routing/GenericDispatcher.php:60

等等

但是,如果您将 Xdebug 配置为在跟踪中显示内存增量,则跟踪文件最终会像这样(注意带有内存增量的额外列,例如 +80):

0.0964    3908336      +84     -> GenericDispatcher->dispatch() /home/tomw/source/public_html/main.php:49
0.0965    3908416      +80       -> ReflectionClass->getMethods() /home/tomw/source/presentation/framework/routing/GenericDispatcher.php:59
0.0965    3910272    +1856       -> ReflectionFunctionAbstract->getName() /home/tomw/source/presentation/framework/routing/GenericDispatcher.php:60 

谁能告诉我如何修改原始表达式以使折叠在第二个示例中正常工作?我无法确定它的头或尾。

谢谢

【问题讨论】:

    标签: vim trace xdebug folding


    【解决方案1】:

    读取的部分

    '^\\s.\\{20\\}\\(\\s\\+\\)\\?->.*$'
    

    正在搜索行首 [^],然后是 1 个空格 [\\s],然后是 20 次重复的任意字符 [.\\{20\\}],然后可选地记住一个或多个空格以供以后使用 [\\(\\s\\+\\)\\? ],最后是一个箭头加上其他任何东西到行尾 [->.*$]。如果您总是要使用额外的列,我只需将 20 个字符的搜索更改为 30 个,如下所示:

    '^\\s.\\{30\\}\\(\\s\\+\\)\\?->.*$'
    

    否则,您可以尝试一个范围,如下所示:

    '^\\s.\\{20,30\\}\\(\\s\\+\\)\\?->.*$'
    

    我还没有真正测试过这些,所以你可能需要稍微调整一下数字,但这应该能让你开始让它工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 2023-03-16
      • 2013-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-08
      相关资源
      最近更新 更多