Closing files before opening the new one
-
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 ?
-
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:
- Close all instances of Notepad++.
- Edit
%AppData%\notepad++\shortcuts.xml
- 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>
- Save
- 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.
-
@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.
-
@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. -
@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 subjectThe 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