3

I just did a fresh install of Notepad++. While Notepad++ was closed, I opened up shortcuts.xml from the C://Users/User/AppData/Roaming/Notepad++ folder (Windows7) and changed the following line:

<Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command>

This change was suggested in an answer to another StackOverflow question: Configuring Notepad++ to run php on localhost?

When I opened Notepad++ after the change, there were no items in the "Run" dropdown menu, and shortcuts.xml was stripped to bare bones as follows:

<NotepadPlus>
    <InternalCommands />
    <Macros />
    <UserDefinedCommands />
    <PluginCommands />
    <ScintillaKeys />
</NotepadPlus>

The reason I did a fresh install was that I already ran into this problem. Although it might seem that it would be a simple matter to just copy and paste the original file, every time I restart Notepad++, the shortcuts.xml file gets wiped out. The only way that I have found to restore shortcuts.xml is by a fresh install, and it looks like there is no way to edit it without it getting wiped out.

I also tried editing the shortcuts.xml in the C://Program Files (x86)/Notepad++ folder. Although the XML file there didn't get wiped out, any changes made there seemed to be completely ignored by Notepad++. According to the the answer in the link I posted above, that is also the wrong file to edit.

I tried Googling the problem, but I didn't find anything.

UPDATE:

Without doing anything except for changing 'Firefox' to 'Mozilla,' it didn't wipe out the file, but as soon as I made the other changes to the line, it wiped it out again. Once it's wiped out, I haven't been able to restore it without a reinstall.

This seems to indicate that it depends on what edits are made. However, I've seen that other people have successfully launched PHP files in localhost from Notepad++, so it looks like this version is a little buggy in some respects.

Community
  • 1
  • 1
Expedito
  • 7,771
  • 5
  • 30
  • 43
  • Did you tell Notepad++ to use %AppData% during the install? (I can't remember if unchecking the option makes it not generate the folder there at all, so I ask.) – BoltClock Jan 07 '13 at 15:13
  • I just did a number of reinstalls trying different options, but I get the same results. New edits above. – Expedito Jan 07 '13 at 15:39
  • According to the FAQ, on topic questions include: "software tools commonly used by programmers." Notepad++ was created for programmers, and launching PHP files from Notepad++ also makes it relevant for programmers. In additin to that, notepad++ has already been accepted as a standard category within StackOveflow. – Expedito Jan 07 '13 at 22:15
  • 3
    Correct; I have no idea why people voted to close your question. I've reopened it. Sorry for the late response as I just got up! – BoltClock Jan 08 '13 at 04:41
  • This may be late for the original question, but if someone is seeking the answer, please check my answer below. – Jackie Yeh Sep 03 '15 at 07:26

4 Answers4

2

shortcut.xml is used by notepad++ while it's running. When you change the shortcut by settings->shortcut mapper, notepad++ will touch shortcut.xml. When notepad++ is closed it will restore keymap back to shortcut.xml. This looks like shortcut.xml was wiped out.

Therefore you CANNOT edit by notepad++ itself. You can use either way to manually modify shortcut.xml:

  1. Close notepad++ first, then edit shortcut.xml by other editor.
  2. Edit shortcut.xml in notepad++ but save to another name, then close notepad++. remove shortcut.xml then rename new saved file to shortcut.xml
Jackie Yeh
  • 1,567
  • 1
  • 9
  • 11
  • I had the same problem and this simple solution worked. Just do not edit notepad++ files with notepad++. Thx Jackie. – Fallen Apart Aug 15 '16 at 22:04
  • This did not work for me. To be 'safe', I copied shortcuts.xml to 2 locations: C:\oldshortcut\shortcuts.xml and C:\newshortcut\shortcuts.xml. I edited the one in "newshortcut" with Microsofts notepad and copied and pasted that back to the original source of the file. I open N++ and... all my macros gone. I then tried the file from the "oldshortcut" folder and... still everything gone! It seems I cannot get my macros back whatsoever. Whenever I make a new macro in Notepad++ it just overwrites my old shortcuts.xml without ever looking at it. – user1261104 Dec 19 '17 at 11:07
1

I successfully modified the configuration file, but it appears trying to do so directly even with a different editor is sometimes not possible. According to the documentation (http://npp-wiki.iwi.me/index.php/Configuration_File_Editing ), it was not meant to be done that way and can be tricky. For that reason, I can't call it a bug, because it was simply not meant to be.

However, I accomplished the same thing through Notepad++ itself. Under the "Run" dropdown, the first item is "Run..." I clicked that, and in the text field I pasted:

"firefox &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;"

And then I clicked "Save." A new dialog box appeared to enter a name for the shortcut and key combinations. I entered "Launch in Mozilla" for the name. After clicking "OK," it kind of gets Twilight-Zonish. It asks for another name, and after entering it and clicking "OK" it does the same thing... and so on... and so on... forever and ever... You can participate in this endless cycle as long as you wish, but I found that you can also simply close the dialog boxes, and everything works out fine.

In the end, my configuration file remained intact even after closing and opening again.

That's the good news. The bad news is that the hack simply didn't work for launching a PHP file in Firefox. In the browser the following appeared:

file:///C:/Program%20Files%20(x86)/Notepad++/&quot;http://localhost/redirect.php?file=C:/htdocs/acrilart/hello.php&quot;

With a blank screen.

However that's a totally different question.

AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
Expedito
  • 7,771
  • 5
  • 30
  • 43
0

Try running Notepad++ as administrator (considering that you use Windows 7).

When I switched to Win7 I was pulling my hair why N++ wouldn't save changes to some config files: because those files were in system folders, Program Files, etc. "Run as administrator" fixed that.

Also: are you editing the shortcuts.xml file in C:\Users\User... or C:\Users[UserName]... ? My installation has a Notepad++ folder only in the latter.

Primoz
  • 626
  • 1
  • 9
  • 16
  • Thanks for the answer, but it doesn't seem to apply. I am successfully editing the files, but Notepad++ is wiping them out afterwards. Are you suggesting that I have to always open Notepad++ as administrator to prevent that? I don't know what you mean. I'm editing the files directly, and as I said, they are not located in the Program Files folder. They are in the path as you said with C://Users/[UserName]/AppData/Roaming/Notepad++. – Expedito Jan 14 '13 at 20:16
  • Right-click N++'s executable or shortcut and one of the options should be "Run as administrator" with a shield icon. Windows will ask for confirmation, select Yes. C:\Users is probably also considered a system folder that requires administrative privileges to edit files. – Primoz Jan 15 '13 at 09:24
  • I know how to run as administrator. That wasn't what I asked, but it didn't matter. It wiped it out anyway, but this time it was an administrative wipe out. :) – Expedito Jan 15 '13 at 11:23
  • Seems I didn't read your comment carefully enough :) The run as admin solution is the most obvious one. Are you editing the file with N++ or some other editor? On N++'s forums it says that it overwrites shortcuts.xml on shutdown ([source](http://sourceforge.net/p/notepad-plus/discussion/331754/thread/2b20af5d)) – Primoz Jan 15 '13 at 12:05
  • As I mentioned in my question, Notepad++ was closed while I made the changes, so yes, I used another editor. – Expedito Jan 15 '13 at 12:17
  • One last idea in case you haven't tried it: `When it looks like a setting is lost, a common cause is that there are two sets of files, one in the %APPDATA%\Notepad++ folder and one alongside Notepad++.exe. Then either N++ doesn't read the right file, or the setting was saved into the wrong file.` [from N++ documentation](http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Configuration_Files) – Primoz Jan 15 '13 at 12:58
  • Thanks for trying to help, but you still haven't read my question carefully. As I already said, I have successfully made changes that are recognized by Notepad++, so it's not possible that I was editing the wrong file. Some changes work fine, but others cause the file to get wiped out. Thanks for helping, but I already found a solution which I will be posting here shortly. – Expedito Jan 15 '13 at 13:08
0
  1. Close Notepad++
  2. Rename the shortcut.xml file to old_shortcut.xml in the C:\Users\\AppData\Roaming\Notepad++\ directory.
  3. Restart Notepad++
  4. Close Notepad++ (You should have the shortcut.xml file you started with.)
  5. Try again editing it again.
  6. Restart Notepad++

If you are lucky this should work. I think there is a size limitation to the Shortcut.xml file or a size limitation to each macro. If it is execeeded step 6 will just wipe the file again. I am running into the same problem.

TheL0grus
  • 99
  • 4