Dialog
Running Saved Commands
If you’ve saved commands, they will show up underneath the Run… entry in the Run menu. You can execute those commands by clicking on them.
Manage Shortcuts
Run > Modify Shortcut / Delete Command will allow you to add or change or delete the shortcut for a command, or remove the command from the Run menu, using the Shortcut Mapper interface. But in short: stay on the Run Commands tab of the Shortcut Mapper to deal with the Run menu entries; Modify will allow you to add or edit a shortcut; Clear will remove the shortcut but leave the command in the menu; Delete will completely remove the command from the menu; Close will exit the Shortcut Mapper dialog.
Example Usage
Run the Current File with its default association
The Windows OS defines default file associations based on the file extension. If you run the command
"$(FULL_CURRENT_PATH)"
the OS will take the saved contents of the file and run them based on the file extension (so a .bat file would run as normal, a .csv might launch a spreadsheet program, a .py file might run your installed Python interpreter, and so on).
Additional Browser Options
The Run menu can be an alternative to the View menu’s View Current File In… submenu: if you don’t like the browser selection available, you can use the “$(FULL_CURRENT_PATH)” shown earlier to run your .html file with your default browser (whatever browser Windows uses when you double-click a .html file). If you want even more options, define additional commands like “c:\program files\alternate browser\browser.exe” “$(FULL_CURRENT_PATH)” to load the active file in whatever browser you want.
Enter Fancy Characters
If you don’t have a fancy Unicode keyboard, or if you want to be able to enter emojis, you could save a run menu command that runs charmap.exe to run windows built-in character map. Or if you have a super-fancy emoji keyboard app, you could run “c:\program files\super fancy emoji keyboard\emojikeyboard.exe” to launch that keyboard from inside Notepad++.
Run your makefile
If you are editing source code, you might want to have a shortcut that will run make or nmake or gmake or similar build program in the current directory.
Getting External Help
You could define Run menu entries to allow you to get help. For example, running the command https://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD) will look up the currently selected word (or the word where your caret is if you don’t have a selection) in Wikipedia using your default browser. Or running https://docs.python.org/3/search.html?check_keywords=yes&q=$(CURRENT_WORD) will look up the current word in the Python 3 online documentation.
A Filename in Your Text
If your caret or selection is on the name of a file in your text, you can open that file in the current Notepad++ instance by running:
"$(NPP_DIRECTORY)\notepad++.exe" "$(CURRENT_WORD)"
Or, if you want to force it to open in a new instance, use:
"$(NPP_DIRECTORY)\notepad++.exe" "$(CURRENT_WORD)" -nosession -multiInst
You Are Limited Only By Your Imagination
If you can run it from cmd.exe or powershell.exe in a single command line, you can run it from here. Let your imagination run wild.
Going Beyond Single-Line Commands
If a single-line command isn’t sufficient for your needs, you may want to consider one of the following options:
- Write a batch file: writing a windows
.bator.cmdor.ps1file using cmd.exe or powershell syntax will allow you to specify a group of commands; you can then just use the Run > Run… to call that batch file to do your more complicated task. You can pass any of the special variables as arguments to this batch file. - Use the NppExec plugin: this plugin can be installed from the Plugins > Plugins Admin interface, and gives you access to a custom batch language, but with extended features that give you access to all the special variables plus extra access to the internals of the Notepad++ interface. This also allows you to view the output of commands in an embedded interactive console window that can be docked in Notepad++. (Does not use the Run menu.)
- Use PythonScript or LuaScript or jN Notepad++ plugins (or similar) to write a script in your favorite programming language (and all those languages should give you access to any feature of that language, plus a way to access applications that live on your filesystem). These may provide interactive console windows to give you even more flexibility. (Does not use the Run menu.)
Security is Your Responsibility
This menu allows you to run arbitrary programs from your PC. Please ensure that you use paths to known safe applications. Understand that you are solely responsible for what happens when you run an external application from Notepad++, and the developers of and contributors to Notepad++ are not responsible for or liable for external commands or the results of running them.
However, starting in v8.9.6.2, the Run menu added extra security-warning that will notify you if the shortcuts.xml was modified manually or outside of Notepad++ (if your file was customized when you upgraded from a version before this to this version or later, the notification will also be used the first time you run a saved entry from the Run menu). In v8.9.7, this protection was extended to also apply to the Macro menu. You can read more in the Config Files > shortucts.xml Security section; but in brief, open shortcuts.xml, verify that your <UserDefinedCommands> and <Macros> entries look correct, then use Run > Validate shortcuts.xml to inform Notepad++ that everything looks reasonable. (This security step prevents a malicious outside actor from overwriting your shortcuts.xml to include a malicious macro or run-menu command, by warning you when there’s an unexpected change to the file.)
