jump to navigation

Launch your program from within Notepad++ February 22, 2009

Posted by razasayed in programming.
Tags: , ,
15 comments

Notepad++ is a good editor for programmers, that supports multiple languages, and also has some other cool features like syntax highlighting, some basic intellisense etc.. . It is free and open source , but the downside is that its available only for Windows . However, it does work on Linux too, by using Wine. Notepad++ is a good alternative for people (especially those using Windows,on Linux  vi or  emacs  are the commonly used editors) who for whatever reason are not using full fledged IDE’s , and want a simple editor with some of the bells and whistles required for their programming work.

Recently, i discovered a cool feature supported by Notepad++, which i thought id blog about . How many times have we encountered situations where we write code in an editor and then switch back to the command line to execute it , especially if we are dealing with interpreted languages like perl, python , ruby etc..

Wouldnt it be nice if we could execute the program within the editor itself  ?. Now that would come in really handy . Would definitely save us some time and overhead involved in the context switch 😉 .

Guess what, Notepad++ being plugin based , has a plugin called NppExec , which allows us to do just that .  All you have to do is download it (assuming this plugin is not already installed)  , then after extracting the archive, place the dll in <Notepad++ Installation directory>/plugins .

Heres how to use it (assuming you are using python , and have the python interpreter installed on your system , however it could be any other language for which you have the corresponding interpreter installed)

Step 1) First type in your program and save the file

Step 2) Go to Plugins->NppExec->Execute (or press F6), and in command section type


python "$(FULL_CURRENT_PATH)"

$(FULL_CURRENT_PATH) , is a Notepad++ internal variable ,that contains the full path of the file currently open in the editor . There is a list of 10 such global variables here

Step 3) Now click on Save, and type a name for this script, so that we can use it again later on.

Step 4) Press OK

Voila, you can now see the output of your program in a console window in the editor itself ! .

Then again when you make some changes to your code, you dont have to go through all the above steps again, simply press Ctrl+F6, which is the shortcut for repeating the previous command.  To switch to a different language you can press F6 and select any other language for which you have saved a script.

Tip : If you dont want those extra messages that you see along with the output, just select Plugins->NppExec->No Internal Messages

Hope someone finds this useful,

Have fun 🙂

Advertisements