• Login
Community
  • Login

Closing files before opening the new one

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 1.5k 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.
  • C
    Cyrille Piatecki 0
    last edited by Apr 17, 2021, 1:45 PM

    When trying to setup an html file often we works by tries and errors. So many html files which are versions of the same one finaly are open in the browser. Is there a way to create a command which closed the old versions and open the new one ?

    P 1 Reply Last reply Apr 17, 2021, 5:06 PM Reply Quote 0
    • P
      PeterJones @Cyrille Piatecki 0
      last edited by PeterJones Apr 17, 2021, 5:07 PM Apr 17, 2021, 5:06 PM

      @Cyrille-Piatecki-0 ,

      I’m not 100% sure I understand what you mean. It seems to me that you have multiple similar source files, which you want to edit one-at-a-time in Notepad++ while viewing one in your web browser. And that you want to automatically close the one you are currently editing when you start to open a new one.

      Personally, I would have all the copies open in multiple tabs in Notepad++, and then just switch the active tab.

      There is an old, no-longer-documented way to get Notepad++ to look more like Windows Notepad: if you exit Notepad++, go into the Notepad++ executable directory and create an empty file called asNotepad.xml, and re-run Notepad++, it will run in a way that no longer shows tabs, and when you open a new file, it is the only file visible. However, if you go to the Windows menu, you will find that the other files are still open, and switch to them there. So it doesn’t technically close the file before opening the new one, but it sure looks like it. (If you want to later get out of that mode, you have to delete that XML file and restart Notepad++.)

      If that’s not sufficient, there is the macro tool . Unfortunately, the File Open isn’t recordable, though it can be in a manually edited macro .

      First, setup the new macro:

      1. Close all instances of Notepad++.
      2. Edit %AppData%\notepad++\shortcuts.xml
      3. Add this inside your <macros> section:
           <Macro name="Close All Then Open" Ctrl="no" Alt="no" Shift="no" Key="0">
               <Action type="2" message="0" wParam="41004" lParam="0" sParam="" /><!-- this will close all active files -->
               <Action type="2" message="0" wParam="41002" lParam="0" sParam="" /><!-- this will launch the File | Open dialog -->
           </Macro>
        
      4. Save
      5. Exit Notepad++

      When you run Notepad++ again, Macros > Close All Then Open will exist, and will run those two commands.

      Using Macro > Modify Shortcut / Delete Command, select Close All Then Open, and assign a keyboard shortcut to your liking, and you now have a keyboard shortcut that does what (I think) you want.

      If this isn’t what you want, you will need to explain yourself better.

      Good luck.

      C 2 Replies Last reply Apr 18, 2021, 9:08 AM Reply Quote 2
      • C
        Cyrille Piatecki 0 @PeterJones
        last edited by Apr 18, 2021, 9:08 AM

        @PeterJones Sorry to have ask two time the same question but I was not sure to have posted it because I didn’t see it in the list.

        1 Reply Last reply Reply Quote 0
        • C
          Cyrille Piatecki 0 @PeterJones
          last edited by Apr 18, 2021, 9:30 AM

          @PeterJones I have tried to follow your advice. But, in my last installation of notepad++, no “C:\Users\cyril\AppData\notepad++”
          has been created. So I have done it, insert “shortcuts.xml” in it and then made the modification. But it seems that notepad++ doesn’t find the path to this file since I have no new macro when I open it.

          P 1 Reply Last reply Apr 18, 2021, 2:30 PM Reply Quote 0
          • P
            PeterJones @Cyrille Piatecki 0
            last edited by Apr 18, 2021, 2:30 PM

            @Cyrille-Piatecki-0 said in Closing files before opening the new one:

            @PeterJones I have tried to follow your advice. But, in my last installation of notepad++, no “C:\Users\cyril\AppData\notepad++”
            has been created.

            %AppData% has a precise meaning, and the path you showed indicates that you need to read the FAQ on the subject

            The other possibility is that you have a portable version rather than an installed version, in which case, shortcuts.xml would go in the portable folder. I doubt that’s your setup, but if you’re unsure, post your ?-menu’sDebug Info.

            But I still think my original instructions apply, and that you just misinterpreted the windows variable

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