How to add custom commands to the Run menu.
First, some caveats: After saving a new entry under a nice name (e.g. “My Command To Do This Or That”), the exact value of the command cannot be viewed or edited from the GUI.
To see what is currently behind that command, you need look into the shortcuts.xml
file,
which is here: C:\Users\<username>\AppData\Roaming\Notepad++\shortcuts.xml (respectively %APPDATA%\Notepad++\shortcuts.xml).
And if you want to modify it, don’t do that while Notepad++ is running, because this XML file will be overwritten when Notepad++ exits and your changes will be lost! So, use another text editor…
Variables
Use them as $(VARIABLE_NAME)
in the command (source):
Variable | Example Value |
---|---|
FULL_CURRENT_PATH | C:\folder\file.ext |
CURRENT_DIRECTORY | D:\current\working\directory |
FILE_NAME | file.ext |
NAME_PART | file |
EXT_PART | ext |
SYS.<var> | SYS.PATH, which is %PATH% |
CURRENT_WORD | the selection or word under cursor |
CURRENT_LINE | the line number |
CURRENT_COLUMN | the column number |
NPP_DIRECTORY | e.g. C:\Program Files\Notepad++ |
NPP_FULL_FILE_PATH | e.g. C:\Program Files\Notepad++\Notepad++.exe |
Example
Here’s a handy shortcut I made for my workflow: “Powershell: Run file and open shell in that directory”:
Powershell.exe -NoProfile -NoLogo -NoExit -Command "& { Set-Location $(CURRENT_DIRECTORY); $(FULL_CURRENT_PATH) }"
DevLog (8)
Film & Television (27)
How To (51)
Miscellaneous (4)
News & Announcements (21)
On Software (8)
Projects (26)