Notepad++ Logo

How To Recover Your Sessions In Notepad++ During Crashes

posted in: Technology | 0

Are you having that annoying and common issue where Notepad++ crashes or won’t start up? There are lots of articles about how to get Notepad++ to start up with the -noSessions and -noPlugins command line argument already.

But how can I recover my drafts and files that were open during my Session?

  1. Go to your user’s data directory such as: C:\Users\yourusernamehere\AppData\Roaming\Notepad++
  2. Open the session.xml file using an editor other than Notepad++ (since it’s crashing) like good ole stable Notepad.
  3. You will see a File record entry for each file that was open before your Notepad++ decided to choke and crash:
<NotepadPlus>
    <Session activeView="0">
        <mainView activeIndex="21">
            <File firstVisibleLine="0" xOffset="0" scrollWidth="2995560" startPos="410" endPos="410" selMode="0" offset="0" wrapCount="1" lang="PHP" encoding="-1" userReadOnly="no" filename="new 1" backupFilePath="C:\Users\yourusernamehere\AppData\Roaming\Notepad++\backup\new 1@2020-11-18_141554" originalFileLastModifTimestamp="0" originalFileLastModifTimestampHigh="0" mapFirstVisibleDisplayLine="-1" mapFirstVisibleDocLine="-1" mapLastVisibleDocLine="-1" mapNbLine="-1" mapHigherPos="-1" mapWidth="-1" mapHeight="-1" mapKByteInDoc="-285211648" mapWrapIndentMode="-1" mapIsWrap="no" />
            <File firstVisibleLine="0" xOffset="0" scrollWidth="1143" startPos="172" endPos="172" selMode="0" offset="0" wrapCount="1" lang="JavaScript" encoding="-1" userReadOnly="no" filename="C:\Ampps\nodejs\helloworld\myprogram.js" backupFilePath="" originalFileLastModifTimestamp="379365449" originalFileLastModifTimestampHigh="30851540" mapFirstVisibleDisplayLine="-1" mapFirstVisibleDocLine="-1" mapLastVisibleDocLine="-1" mapNbLine="-1" mapHigherPos="-1" mapWidth="-1" mapHeight="-1" mapKByteInDoc="-285211648" mapWrapIndentMode="-1" mapIsWrap="no" />
            <File firstVisibleLine="0" xOffset="0" scrollWidth="4284" startPos="90" endPos="90" selMode="0" offset="0" wrapCount="1" lang="HTML" encoding="-1" userReadOnly="no" filename="new 2" backupFilePath="C:\Users\yourusernamehere\AppData\Roaming\Notepad++\backup\new 2@2020-11-23_163159" originalFileLastModifTimestamp="0" originalFileLastModifTimestampHigh="0" mapFirstVisibleDisplayLine="-1" mapFirstVisibleDocLine="-1" mapLastVisibleDocLine="-1" mapNbLine="-1" mapHigherPos="-1" mapWidth="-1" mapHeight="-1" mapKByteInDoc="12513024" mapWrapIndentMode="-1" mapIsWrap="no" />
</mainView>
        <subView activeIndex="0" />
    </Session>
</NotepadPlus>

This shows you the location of the temp files. These files you can open directly with regular Notepad and save them as regular docs or text files somewhere for safe-keeping.

Go to the backup folder listed in the session.xml to get your content back:
C:\Users\yourusernamehere\AppData\Roaming\Notepad++\backup\