Menu

How to add new Functions to the Run Menu

clawlor
2008-07-08
2012-11-13
  • clawlor

    clawlor - 2008-07-08

    It is possible to change the functions performed by the Run menu. In my case, I wanted to be able to search the Python docs for the current word, like the 'search PHP help' run command. This will work in Notepad++ 5.0, YMMV for other versions
    Begin by locating the 'shortcuts.xml' file on your system. Mine was in C:\Documents and Settings\USER_NAME\Application Data\Notepad++. It could also be in your Notepad++ installation directory depending on the option you chose during installation.
    Make a copy of shortcuts.xml, and open the copy with your favorite text editor (I assume you'll use Notepad++ :). Around line 15 you'll see a UserDefinedCommands section filled with Command lines. We'll be changing one of the existing Command functions. Since I don't program in PHP much, I chose to get rid of the 'search PHP help' function, and instead, search Python.org for the current highlighted word in the text buffer.
    To make the change, simply change the 'search PHP help' text in the 'name' attribute of the Command line to something like 'search Python.org'. To change the behavior, we'll need to find out what to change the Command to. To get the proper URL, I went to Python.org, and did a test search for 'TEST'. Python.org uses Google, so I got this URL in my address bar:
    http://www.google.com/search?sourceid=python-search&q=TEST&submit=Search&q=site%3Apython.org
    This URL is exactly what we need for our new command, so copy/past the URL into the Command line over the old command. Next, replace the word TEST with $(CURRENT_WORD), so that we can search for the current highlighted word instead of just searching TEST all the time.
    Now we can switch out the old and new versions of shortcuts.xml. Notepad++ must be closed for this step. Now, rename the old shortcuts.xml to something like shortcuts.xml.bak, and rename the new version to shortcuts.xml. Re-open Notepad++, and you should see the new command in the Run menu

     
    • Nobody/Anonymous

      Why not save a new one using  the menu itself? You should be able to do the exact same thing without any hassle of editing the XML file, which could be done incorrecly :)
      Press F5, type the command (dont forget quoting if needed) and save instead of run, it wil lbe added to the menu.
      To remove it, go to the shurtcutmapper, then user commands and rightclick on the one you want to remove, you canselect delete.

       
      • clawlor

        clawlor - 2008-07-08

        You know, that seems quite obvious now that you've pointed it out, thanks!