When I'm using textmate, I simply hit "apple+r" and the program gets interpreted. How can I run a program from within notepad++? I see that F5 is for "Run", but pointing that to Python.exe simply opens up a terminal with python running. It does not run my script.
6 Answers
Plugins NppExec Execute (F6) is much more powerful than plain Run (F5). Install NppExec via Plugins, Plugin Manager. Then in F6 add/save the following:
NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
C:\Python34\python.exe -u "$(FULL_CURRENT_PATH)"
In Plugins NppExec Console output filters (Shift+F6) add the following HighLight mask:
*File "%FILE%", line %LINE%
Make sure it's checked, and make it e.g. red and underlined.
Upon "F6/execute" errors will be highlighted and clickable !
This works in NPP568, possibly older.

- 17,623
- 11
- 91
- 124

- 611
- 5
- 4
-
1ABSFILE didn't work for me, I had to use this: ****File "%FILE%", line %LINE%, in**** – Martin Sherburn Apr 15 '11 at 08:25
-
Works for me (php in my case), and is (double-)clickable, BUT double-clicking only navigates the specified line number in the active file, it doesn't open the file indicated by %ABSFILE%. This makes clickability almost useless when working on library scripts. – yoyo Mar 16 '12 at 00:04
-
2To make this work for syntax errors (as well as runtime errors) use `*File "%ABSFILE%", line %LINE%`. The `, in*` part won't match on syntax errors as they don't mention the module where the error occurs. – Eric Jun 18 '12 at 19:50
-
1If you want to make this super convenient, you can also set up a console shortcut like so: `npe_cmdalias p = python "$(FULL_CURRENT_PATH)"`. This means you can simply popup the console view, type `p` and your script will run. – Assad Ebrahim Aug 20 '12 at 03:29
-
The execution window keeps popping up though. Is there a way to suppress this? I want to be able to push F6 and immediately see console output without having to manually close the window each time. – Jan M. Sep 30 '15 at 16:32
-
-
1
You need to pass through the FULL_CURRENT_PATH environment variable to the program, as described in the notepad++ wiki:
python "$(FULL_CURRENT_PATH)"

- 489,969
- 99
- 883
- 1,009
-
-
New link: [notepad++ wiki](http://docs.notepad-plus-plus.org/index.php?title=External_Programs) – ands Jul 29 '18 at 19:37
You can use PyNPP Plugin (https://github.com/mpcabd/PyNPP) to achieve this.
I know this is old but the answer is for people coming from search.

- 1,813
- 15
- 20
possible to use pdb too
The answers above were very useful to get it working. However, once i could run the python programs, I also needed to interact with them. Two things I found out.
- Use "python -u -i $(FULL_CURRENT_PATH)" if you wish to interact with your program (like giving command line inputs).
- to use the awsome PDB, use "python -u -m pdb $(FULL_CURRENT_PATH)" and then you can easily debug your programs as well. :-) loving it!!

- 569
- 7
- 10
if u have the NppExec plugin (is by default) hit F6 and add the command that exec your script
python /path/to/script.py

- 23,695
- 8
- 85
- 109
Unless I'm missing something, the other answers discussing NppExec do not provide a way to run the script with a single keystroke or (the execute dialogue box always pops up when F6 is pressed which must be accepted before the script is run).
After completing the steps in bjornhb's answer the following will allow you to run scripts with just one keystroke:
- Under Plugins->NppExec->Advanced Options create a new Menu Item. I simply named mine Python. Select the script which was saved earlier in the Associated script dropdown box and click Add/Modify. Click OK.
- Restart Notepad++
- Under Settings->Shortcut Mapper click the Plugin commands tab at the top. Scroll down and find your command name on the left hand side. Double click inside the white box in the Shortcut column next to your command name. Select an appropriate key (or combination) and accept. Pressing the shortcut key(s) will run the script without further input.

- 1
- 1

- 1,625
- 3
- 16
- 29