【问题标题】:Find in Files - Number per file在文件中查找 - 每个文件的数量
【发布时间】:2020-06-27 13:27:34
【问题描述】:

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

【问题讨论】:

    标签: emeditor


    【解决方案1】:

    在文件中查找之后,您可以在结果文档处于活动状态时运行此宏。例如,将此代码另存为statistics.jsee,然后从Macros 菜单的Select... 中选择此文件。最后,执行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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-01
      • 2020-10-07
      • 2014-02-26
      • 1970-01-01
      • 2016-07-15
      • 1970-01-01
      相关资源
      最近更新 更多