Notepad++ Is there a setting to stop from asking me to save on exit?

49

10

I'd like the option to have Notepad++ exit, and close individual tabs without asking me if I want to save every file where edited.

I tend to run with a lot of tabs open, and am capable of remembering to save when I need to. Being asked to save when closing multiple is annoying, and a little dangerous in that if the modal dialogue box moves on each tab, there is a chance of accidentally hitting yes when I didn't mean to.

gb2d

Posted 2015-08-06T07:46:21.577

Reputation: 828

There is a feature request for this, please support it: https://notepad-plus-plus.org/community/topic/11784/feature-request-close-all-files-without-saving

– Joe – 2018-01-10T07:15:29.423

I downvoted this question for low quality because after providing the answer, it turned out that there are further requirements not mentioned in the text of the question. The correct approach would be early correction of the question or keeping original requirements (so Q and A go nice together) and post another question with detailed description of special requirements of the author different from the original question. – miroxlav – 2018-07-25T16:39:04.423

Answers

73

Yes, there is. In Backup page of Preferences, be sure you check

  • Remember current session for next launch

  • Enable session snapshot and periodic backup

enter image description here

▶ Then Notepad++ exits immediately without asking.

Open documents are retained, but it is as easy as pressing Ctrl+W to close them. You can also assign some shortcut to Close All command (suggestion: Ctrl+Shift+W).


EDIT: You can close individual tabs if they have no name yet without warning (but keeping Notepad++ open) when you press Ctrl+A and then Delete right before closing the tab. You can even try to create a macro for that. If not Notepad++ macro, then AutoHotKey macro will easily do it.

Note that there is no way to do this for unsaved documents which already have the name. I checked the source code. So after closing unnamed documents you can get rid of the rest by using Save All command and then closing any remaining documents you want.

If your tabs are mixed (new, exsting, new, existing, ...), it is better to create AutoHotKey macro which invokes closing and then presses No button in case if the save dialog appears. This will close current tab without saving regardless of its new or existing state.

There is yet another option how to avoid the question on closing a tab: you can download source code of Notepad++, modify it (so the dialog is never shown), build it and start using your own Notepad++ build.

You can also request the feature at N++ home page, but here is the risk that it could be viewed as rare corner-case and you might be waiting very long until someone implements it (if ever).

miroxlav

Posted 2015-08-06T07:46:21.577

Reputation: 9 376

This doesn't work I'm afraid. While it allows Notepad++ to exit entirely with out a save prompt, it does not work for closing individual tabs. If you close a tab and the document has been edited, it still prompts and asks if I want to save the file. – gb2d – 2015-08-08T18:25:36.950

1@gb2d – Sure, but in title you said Is there a setting to stop from asking me to save on exit? and this is what the answer shows. You then continue I'd like the option to have Notepad++ exit, and close individual tabs without asking me if I want to save every file where edited. My answer describes exactly this functionality. :) Perhaps you meant closing individual tabs without asking, keep N++ open but that is completely different question from what you wrote... What now? It is not allowed to change question merit, but you can always post a new question clearly specifying what you need. – miroxlav – 2015-08-08T18:43:40.770

OK, I've extended the answer to reflect the requirement you described in the comment. – miroxlav – 2015-08-08T19:16:07.423

Ctrl + A, then delete - so select all text, delete it and then close? That still prompts to save if deleting the text results in the file changing from it's original state. Your suggestion of customising the source may be the way to go here however. I will look into that. – gb2d – 2015-08-09T07:57:57.187

See the updated answer. Close unnamed tabs first, then Save all and continue closing named tabs. I checked against the Notepad++ source code to confirm under what conditions save dialog is displayed. All possible ways are now covered by the answer so you can accept it as reliable one. – miroxlav – 2015-08-09T08:36:57.030

Sorry, but this answer just does not represent a shortcut that achieves what I specified in my question. Your advice regarding use of shortcut mapper has been useful however, and I think I can use this in conjunction with repeated presses of the N key to close any save dialogues. – gb2d – 2015-08-10T07:58:03.817

Sorry but no better or more helpful answer exists. Perhaps, there is one: No there is no way of achieving this except source code modification. If I'll make this the main point of answer, would you accept this? What else are you waiting for? – miroxlav – 2015-08-10T08:22:27.947

@gb2d – I think I might be able to create that non-standard solution you expect using the AutoHotKey. It will handle asked questions in Notepad++ until it is closed. Are you interested?

– miroxlav – 2017-12-28T09:02:56.473

6

I just had this problem when I had demonstrated to a colleague how to find/replace on 150 files in a folder I didn't have write access to. My solution is a bit of a hack, but it works. I went into C:\users\[username]\AppData\Roaming\Notepad++\backup and deleted all the files in there. Then I force-quit Notepad++ with the task manager and open it back up. It still has the files I had open but now they show as unchanged, so I can hit Close All and they close without dialogs.

An alternate option appears to change the session.xml file in there and just take out all the files you had open.

partofthething

Posted 2015-08-06T07:46:21.577

Reputation: 181

@gb2d – this is a clever answer. Perhaps something acceptable for you? – miroxlav – 2017-06-02T10:37:40.527