Sessions And Projects
Sessions keep track of what files are opened in Notepad++, with some extra information like file positions and highlighter for the file. The detailed contents of session files is described in the relevant section of Editing Configuration Files. Sessions do not backup files - see Settings -> Preferences -> Backup/Auto-Completion about this.
There are exactly 4 controls in Notepad++ that relate to sessions:
- File -> Load session....
- File -> Save session....
- Settings -> Preferences -> MISC -> Remember current session for next launch
- Settings -> Preferences -> MISC -> Session file ext.:
This page is about using sessions to manage projects (see Project Management) because it is their main use and because, before version 5.9.4, it was the only available tool.
Start a new project
Open all existing file that are to be on the project. You can plan for the future by adding a few new files you expect to have contents soon. Click File -> Save session, and save to some session file.
If you have some foresight, create a project folder first, and then save the current session. We'll see later how this can be useful.
Open Notepad++, then click File -> Load session. Choose your session file. Now either open the file to be added, or close file to be removed. File -> Save session, you are done. By the way, the last current session is remembered in <Notepad++.exe folder>\session.xml.
They are plain xml files, with some obvious structure you can borrow from existing session. This means you can edit them manually, if this is easier. In particular, session files will record bookmarks and how text is folded.
By default, session files have the .xml extension, but you can change that from Settings -> Preferences -> MISC -> Session file ext (look in the lower right corner).
session.xml does not get renamed when you change the default session extension. This is not an issue, because you can ask Notepad++ to load any file, as long as it has contents that can be understood.
Rename a project
Rename the project session directory, or the desired session file.
Open part of a project
Select the session that corresponds to the desired part. That's where keeping them in a single folder may help.
All requirements were covered, but there are more features.
One instance, two views
Notepad++ supports two independent views - see Multiple Views -, and the files in each are recorded into any created session files. In a nutshell, you get two project views per session. If some couple of subprojects are (expected to) be used together often, this will help reducing the number of session files for a project - expectedly halving it.
Yes, there is something still missing: the ability to see the contents of a session file as an Explorer-like tree view. Notepad++ is not a dedicated XML editor. It could be an interesting plugin to write.
Session files on the command line
Since session files can be given a default extension that causes Notepad++ to load them as session files, you can define a User command with the name of the session file. Executing the command will open all the files remembered in the session.
If the contents of a session file are not valid, Notepad++ will not open the file. For this reason, you should use an extension that to your reasonable knowledge is not shared by anything on your system. In particular, .xml would be about the worst possible choice.