Macros not saving
-
@Robert-Roth One test you could try is to go to Settings / Shortcut mapper and to change any shortcut. You can add a new keyboard mapping, change one of the existing ones, or delete/clear one of them.
Now, exit Notepad++ and take a look at the file date/time for
%AppData%\Notepad++\shortcuts.xml
The date/time should be the current time or within the last couple of minutes.If the
shortcuts.xml
file was modified as expected then restart Notepad++ and verify that the keyboard shortcut you modified is in the state you left it in. You can now fix the shortcut and then exit Notepad++ to save that change back to disk.If the
shortcuts.xml
file was not modified according to the date/time stamp then we can dig into permissions.I did a test and discovered that if your shortcuts.xml file is set to read-only that Notepad++ silently won’t update the shortcuts.xml. From a command prompt do:
cd /d "%appdata%\notepad++" attrib shortcuts.xml
If you see a
R
floating to the left of shortcuts.xml then it’s a read-only file. Clear the read-only flag using:attrib -r shortcuts.xml
-
I added an issue report to github about If shortcuts.xml or config.xml are read-only then Notepad++ silently won’t save changes to those files.
We don’t know yet if @Robert-Roth’s underline issue is that the shortcuts.xml file is read only.
-
@mkupper said in Macros not saving:
I did a test and discovered that if your shortcuts.xml file is set to read-only that Notepad++ silently won’t update the shortcuts.xml
Hmm, are there other ways for this file to become read-only other than a user explicitly setting it this way? If not, then I’d say “user knows what he is doing”, and he is really and truly achieving what he expects, i.e. protecting something from change.
-
@Alan-Kilborn said in Macros not saving:
Hmm, are there other ways for this file to become read-only other than a user explicitly setting it this way?
We don’t know if in this case the file is read-only. I was thinking about the behavior the OP reported, and as an experiment made the shortcuts.xml read-only. I learned that Notepad++ silently ignores errors or does not check for errors when saving the shortcuts.xml and config.xml files. That’s what lead to the github report.
My concerns are about 1) Notepad allowed someone to make changes to their settings even though the configuration file(s) were read-only. The user was not alerted that their changes would only be good for the current session and that Notepad++ would revert its configuration. 2) Notepad++ failed to inform the user when there were errors attempting to save the configuration and that it was not saved.
A user could accidentally set a file to read-only. When you have the file properties dialog box up then read-only is one of the tick boxes.
A user could also intentionally set set a file to read-only but ideally should make it clear to Notepad++ that this is intentional. I don’t know if it’s desirable to be able to structure things so that the settings won’t be saved and the user is never notified.
-
I don’t know where a user’s responsibility ends and it is up to the computer to save him from himself. I come from a time when the user was “very responsible”, so…I think I do know. :-)
Setting a file as “read only” via the operating system (as opposed to a program feature) is the user subverting the system, and that’s OK because user supposedly knows what he’s doing when he does this.
With over 2000 open issues, I’d rather see Notepad++ developers do other things with their time, rather than try to “save the user” from the circumstance of a read-only config file, that the user made read-only himself (again this assumes that some outside influence didn’t make it read-only, but it hasn’t been shown that is reasonably possible). But that’s just me.
-
@Terry-R said in Macros not saving:
Whenever I edit the shortcuts file in NPP, I do so in a new session, with absolutely no other instances of NPP running. Edit it, save and close NPP before reopening and using NPP as normal.
As for normally saving a macro, if you are running multiple instances of NPP the last instance closed, if it needs to update the shortcuts file, will do so and maybe that has been your issue?
I (almost) never have a second instance running, and that certainly wasn’t the case when I ran my tests above.
-
@mkupper said in Macros not saving:
One test you could try is to go to Settings / Shortcut mapper and to change any shortcut. You can add a new keyboard mapping, change one of the existing ones, or delete/clear one of them.
Now, exit Notepad++ and take a look at the file date/time for %AppData%\Notepad++\shortcuts.xml The date/time should be the current time or within the last couple of minutes.
Test #2 in my list essentially is the same. I was watching the timestamp, and it didn’t update.
If the shortcuts.xml file was not modified according to the date/time stamp then we can dig into permissions.
I did a test and discovered that if your shortcuts.xml file is set to read-only that Notepad++ silently won’t update the shortcuts.xml.
runningattrib
on the directory shows only the Archive bit is set on all files. This is true whether or not NPP is running. -
@PeterJones said in Macros not saving:
That normally would, but given your other results, it’s sure behaving like a permissions problem.
the Windows
icacls
utility will give you some permission information. In my working setup, I get:I get identical output when I run
icacls
.I’ll give your other 2 options a try tomorrow. It’s time to clock out.
-
@Robert-Roth Try this:
Exit/close Notepad++
and then from from a command prompt run the following commands. Note that you can copy/paste from the forums into a command prompt window by hovering the mouse over the list of commands below. An icon should appear in the upper-right corner. Select that and the full text of the box gets loaded into the copy/paste buffer. Switch to or start a Command Prompt window and right click in the text area to paste.cls & rem This will clear the screen cd /d %appdata%\notepad++ type shortcuts.xml >tmp ren shortcuts.xml shortcuts-bad.xml ren tmp shortcuts.xml dir /a-d
The goal is to create a copy of the shortcuts.xml file but with a brand new set of permissions or other weirdness.
Click on the small command prompt in the upper-left corner of the Command Prompt window and select
Edit / Select All
which will make the screen all white with black text. Right click the mouse once within the command prompt. It will go back to it’s usual colors and also loads the full screen into the copy/paste buffer.Paste the results into the forums in a format like this including the lines with three back ticks (`)
```
(paste here)
``` -
@mkupper Whelp, that fixed it. Once I replaced it with the former
tmp
, it worked just fine, and I’m able to modify macros.Still not quite sure why this was the case, but this definitely is a simpler test/fix than making a copy of the entire directory.
Thanks, everyone, for the assistance.