How could one sort the files in the "Recent Files" menu in "Files" by date / last closed or alphabet?



  • How could one sort the files in the “Recent Files” menu in “Files” by date / last closed or alphabet?



  • @Cletos

    • Sorting of the recent files list by “last closed” order would require changes to the Notepad++ code base, thus you should file a feature request in the issue tracker. Read this help desk entry to learn how to do that.
    • Sorting the list by file date would require scripting. Since this is not a scripting forum you should look for support at another website.
    • Alphabetical sorting of the recent files list can be done with the help of the following XSLT code:
    <?xml version="1.0" encoding="Windows-1252"?>
    
    <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:output
        method="xml"
        encoding="Windows-1252"
        indent="yes"
        omit-xml-declaration="no"
      />
    
      <xsl:template match="@*|node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="/NotepadPlus/History">
        <xsl:copy>
          <xsl:copy-of select="@*"/>
          <xsl:apply-templates select="File">
            <xsl:sort select="@filename"/>
          </xsl:apply-templates>
        </xsl:copy>
      </xsl:template>
    
    </xsl:transform>
    

    To apply that code on the Notepad++ settings file you need msxsl.exe, a command line XSLT processor released by Microsoft. You can download it >>> here <<< or just google for msxsl.exe.

    With the following commands executed from a console window you can sort the recent files list:

    ren "%AppData%\Notepad++\config.xml" "config_backup.xml"
    msxsl "%AppData%\Notepad++\config_backup.xml" "<Path-to-file-with-above-XSLT-code>" -o "%AppData%\Notepad++\config.xml"
    

    Please note:

    • Run these commands only when there is no running instance of Notepad++.
    • The commands assume you use an installed version of Notepad++. If you use a portable version you have to adjust the path to the file config.xml.
    • The commands back up your original config.xml to a file named config_backup.xml in its original location, thus you won’t loose your original file.


  • @dinkumoil said in How could one sort the files in the "Recent Files" menu in "Files" by date / last closed or alphabet?:

    Sorting of the recent files list by “last closed” order would require changes to the Notepad++ code base,

    Isn’t the list already in “last closed” order? Maybe I’m missing something, or I don’t understand the meaning of “last closed”.



  • @Alan-Kilborn said in How could one sort the files in the "Recent Files" menu in "Files" by date / last closed or alphabet?:

    Isn’t the list already in “last closed” order?

    You are right, it is. The last closed file is the top one. Never noticed that as I normally work with so much different files that the “Recent Files” list is mostly useless for me.



  • Many thanks, dinkumoil,

    for the instructions, very easily done. Works great! Many thanks again!


Log in to reply