Community
    • Login

    Is there a way to close the window without confirming the save?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 5 Posters 4.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • piglingcnP
      piglingcn
      last edited by piglingcn

      When i open many files,i just want to keep one and close other files without save.
      I think this would be a popular feature .
      thanks reading.^-^

      dinkumoilD 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        @piglingcn said:

        keep one and close other files without save.
        I think this would be a popular feature .

        Funny, I would think that most people would be horrified that if they chose “close all but this file”, it would throw away all the changes they made in all the other files. But maybe you have a use-case I cannot imagine.

        If you really want to request this feature, this faq explains where to make feature requests so that they can be properly tracked. But be prepared to have to explain exactly what you want, justify why you think it’s a good idea, have people disagree with you, and potentially have the request rejected by the developer or ignored for years to come. (The same potential scenario is true for any feature request, not just this particular request, so I’m not trying to pick on you.)

        1 Reply Last reply Reply Quote 4
        • Alan KilbornA
          Alan Kilborn
          last edited by Alan Kilborn

          I think from observing some of the Notepad++ source code commits on github recently, that a feature that will help out the OP is coming soon to Notepad++.

          What the OP would do is right-click the tab of the one file they are interested in keeping, then choose Close All BUT This. A dialog box will come up and will have a No to All option (this is the recently committed code) when N++ asks to save files, which the OP would select.

          1 Reply Last reply Reply Quote 6
          • dinkumoilD
            dinkumoil @piglingcn
            last edited by dinkumoil

            @piglingcn

            Indeed, as @Alan-Kilborn already said there is a feature in the pipeline that will help you out. But since we are in holiday times and there are problems with the Notepad++ download server it may take a while until the next release. In the meanwhile you could use the NppExec scripting plugin and the following script as a workaround:

            npp_console keep
            npp_console disable
            npe_console -- m-
            
            set local MainViewId ~ MAIN_VIEW
            set local SubViewId ~ SUB_VIEW
            set local PrimaryView ~ PRIMARY_VIEW
            set local SecondView ~ SECOND_VIEW
            
            npp_sendmsg NPPM_GETCURRENTBUFFERID
            set local CurBufId = $(MSG_RESULT)
            
            npp_sendmsg NPPM_GETCURRENTVIEW
            set local CurViewId = $(MSG_RESULT)
            
            if $(CurViewId) == $(MainViewId) then
              set local CurView = $(PrimaryView)
              set local OtherView = $(SecondView)
              set local OtherViewId = $(SubViewId)
            else if $(CurViewId) == $(SubViewId) then
              set local CurView = $(SecondView)
              set local OtherView = $(PrimaryView)
              set local OtherViewId = $(MainViewId)
            else
              exit
            endif
              
            set local Cnt = 0
            
            :RepeatLoop
              npp_sendmsg NPPM_GETNBOPENFILES 0 $(CurView)
              set local Idx ~ $(MSG_RESULT) - 1
            
              :ForHead
              if $(Idx) < 0 goto ForEnd
                npp_sendmsg NPPM_ACTIVATEDOC $(CurViewId) $(Idx)
            
                npp_sendmsg NPPM_GETBUFFERIDFROMPOS $(Idx) $(CurViewId)
                set local BufId = $(MSG_RESULT)
                
                if $(BufId) != $(CurBufId) then
                  npp_sendmsg NPPM_RELOADBUFFERID $(BufId) 0
            
                  if $(MSG_RESULT) == 1 then
                    npp_sendmsg NPPM_MENUCOMMAND 0 IDM_FILE_CLOSE
                  endif
                endif
            
                set local Idx ~ $(Idx) - 1
                goto ForHead
              :ForEnd
              
              set local CurViewId = $(OtherViewId)
              set local CurView = $(OtherView)
              set local Cnt ~ $(Cnt) + 1
            if $(Cnt) <= 1 goto RepeatLoop
            

            The script will close all unsaved files if they are real files on disk. Newly created files (whose names are like new 1, new 2 and so on) will stay open.

            1 Reply Last reply Reply Quote 5
            • Munsen TidocoM
              Munsen Tidoco
              last edited by

              Here you have the answer.
              It is very useful to close everything from time to time.

              https://notepad-plus-plus.org/community/topic/16562/close-all

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors