How to launch a program from Notepad++?

9

5

Some text editors, like Notepad2, have the ability to run the file that's being edited. Can this be done with Notepad++?

tony_sid

Posted 2010-08-17T04:33:45.827

Reputation: 11 651

Answers

8

First close Notepad++, then find the file shortcuts.xml, usually in:

  • Windows 7/8/10: C:\Users\<username>\AppData\Roaming\Notepad++
  • Windows XP: C:\Documents and Settings\<username>\Application Data\Notepad++

Open it up with something other than Notepad++ (perhaps notepad.exe) and add something like this to the file within the <UserDefinedCommands></UserDefinedCommands> tags:

<Command name="Launch file" Ctrl="yes" Alt="yes" Shift="yes" Key="">&quot;$(FULL_CURRENT_PATH)&quot;</Command>

That will launch the (saved) file with its default application.

Save the changes and then load up Notepad++ to see your new entries in the Run menu.

Important: do not edit shortcuts.xml with Notepad++ itself as the shortcuts.xml file is overwritten when the program shuts down (overwriting any changes you made).

boot13

Posted 2010-08-17T04:33:45.827

Reputation: 5 551

If I put that in and then start Notepad++, it's not there . – tony_sid – 2010-08-17T08:50:14.357

Notepad++ is kinda weird about where it gets its settings. If that file didn't work, try the same file in the main Notepad++ application folder. Also, don't use Notepad++ to make the change to the file. One more thing: make sure to add the new line in the UserDefinedCommands section along with the other Command entries. – boot13 – 2010-08-17T10:30:20.937

I tried this, and assigned the key to F5 (after clearing it from any existing commands), but F5 doesn't launch the script file. I created an entry for Execute with the code above, except for the hotkey. I'm trying to launch a .ahk script. The menu command works, but the hotkey doesn't. I just want F5 [cries]. – bgmCoder – 2017-08-23T22:49:15.527

@bgmCoder: I was able to make it work with Ctrl-Alt-Shift-F5, so the keyboard shortcut mechanism does work. I'm thinking that the F5 key is handled in some special way, despite the fact that you can unassign and assign it in the Shortcut Mapper. – boot13 – 2017-08-24T16:11:59.923

@boot13 Yeah, I think there is a bug somewhere. But I want F5! waaaaa! It's what I use in other applications. – bgmCoder – 2017-08-24T22:20:22.987

Is there any way of adding saving to this as well? i.e. Save file and then launch the (now saved) file with its default application? – olagjo – 2013-02-06T17:05:00.993

@olagjo: apparently not. You should probably look at using the NppExec plugin. – boot13 – 2013-02-07T11:02:38.217

4

I guess you mean a Plugin to execute xour commands or scripts. There is an officially supported Plugin for that on the N++ Plugindirectory called NppExec

Diskilla

Posted 2010-08-17T04:33:45.827

Reputation: 1 516

2

The answer by boot13 is a little overly complicated. The Run menu and command will do this. It also has the ability to save the command with an assigned hotkey. This is then saved to the UserDefinedCommands.

The option that I prefer is the NppExec plugin. This is far more capable and flexible when choosing how to run a program, and can run things in the command line with console output as well as launching windows applications.

Andrew Redd

Posted 2010-08-17T04:33:45.827

Reputation: 1 294

1I'm glad that works for you, because any time I've tried it, the result is inconsistent. For instance, I just tried it again, and while (this time, anyway) it did add the command to the list, selecting that command does nothing at all. To avoid the frustration, I prefer showing people how to edit the file directly. – boot13 – 2010-09-13T20:40:15.963

2

NPPExec didn't work for me so I tried the "RunMe" plugin written by F. Stellari which works like a charm. It executes files based on their extension simply by pressing a key or a key combination.

By default RunMe is "Shift + F5" but you can easily change this to F5 changing Notepad++'s keyboard shortcut settings.

Current download url is: http://sites.google.com/site/fstellari/nppplugins

If this should change, search for "notepad++ runme"

Fritz

Posted 2010-08-17T04:33:45.827

Reputation: 21

I've tried this, but F5 doesn't do anything. You can un-assign it from the default Run command, and reassign it to RunMe's command, but the hotkey doesn't work. – bgmCoder – 2017-08-24T22:17:40.283