我对 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
谁能告诉我如何修改原始表达式以便折叠在第二个示例中正常工作?我无法确定它的头或尾。
谢谢