1

在 EMEditor 中,有没有办法获取每个文件“在文件中查找”搜索的出现次数?换句话说,它在 25 个文件中找到了 10,000 个“命中”,我想知道 file1 中的 1200
个等。Notepad++ 通过允许您按文件折叠结果并显示每个文件的摘要,在这方面做得很好,但我还没有看到在 EMEditor 中获取信息的方法。

4

1 回答 1

0

Find in Files之后,您可以在结果文档处于活动状态时运行此宏。例如,将此代码另存为 , statistics.jsee然后从菜单中的选择...中选择此文件。最后,执行Find in Files ,并在结果文档处于活动状态时在Macros菜单中选择Run 。

// Creates statistics from Find in Files Results.  
// 2020-06-27
Redraw = false;
sOutput = "";
y = 1;
yMax = document.GetLines();
for( ;; ) {
    document.selection.SetActivePoint( eePosLogical, 1, y++ );
    document.selection.Mode = eeModeStream | eeModeKeyboard;
    bFound = document.selection.Find("\\(\\d+?\\)\\:",eeFindNext | eeFindReplaceCase | eeFindReplaceRegExp,0);
    document.selection.Mode = eeModeStream;
    if( !bFound ) {
        break;
    }
    sFile = document.selection.Text;
    n = sFile.lastIndexOf("(");
    sFile = sFile.substr( 0, n );
    nCount = 1;
    for( ;; ) {
        document.selection.SetActivePoint( eePosLogical, 1, y );
        sLine = document.GetLine( y );
        if( sLine.length > sFile.length && sLine.substr( 0, sFile.length ) == sFile ) {
            ++nCount;
            ++y;
        }
        else {
            sOutput += sFile + "\t" + nCount + "\n";
            break;
        }
    }
}
document.selection.Mode = eeModeStream;
Redraw = true;
editor.NewFile();
document.write( sOutput );
editor.ExecuteCommandByID(4471);  // switch to TSV mode
于 2020-06-27T15:50:33.257 回答