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



  • 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.^-^



  • @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.)



  • 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.



  • @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.



  • 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


Log in to reply