Notepad++ is a free and powerful text editor which is making the work for developers and programmers so easy to edit code in multiple programming languages without shifting to another specific language text editor to edit or write the code.
It has the great support of numerous plugins to make you even more productive.
First thing first:
At the end of the Post you will be able to:
- Compile and run any language code with just using a common shortcut for all languages (I personally like
ALT+Zbecause keys are closer …lazy coders 😛 )
- If you only want to compile the code with a shortcut that’s cool too ( like
ALT+C..see ..again laziness)
- If you choose to only run the program with shortcut that’s fine (like
ALT+Xor anything less lazy )
The shortcuts you will set will work for all languages. The Script which I’ll provide automatically detects the compiler for the corresponding language and run the program.
There are 2 ways by which you can see the output of a program:
1. Inside the Console window of Notepad++:
2. Or in Command prompt of Windows:
I personally like to see the compilation errors (if any) in Notepad++ console but run the program in cmd ( yup! we can configure this too 😀 )
So, let’s build the stuff:
1. Install Notepad++ from here and install it.
- Apply some dark theme in Notepad++ (to feel more geekish 😀 )
- Go to
Notepad++ -> Settings -> Style Configuratorthen follow below image to set theme:
2. Install a plugin called ‘NppExec’:
This plugin lets you create command macro within a built-in console of Notepad++ and prints the results in that console
- Go to
Notepad++ -> Plugins -> Plugin Manager -> Show Plugin Manager
Npp_Exec, install it and restart Notepad++
3. Install necessary Compilers and set PATH of Compilers in ‘System Variables’.
3.1 Download compilers for languages you want to run:
💡 The script will still work properly if you skip some compilers.
( I’m looking at you C/C++ Coders 😈 )
- Download latest “JDK” from here (install JDK not JRE) (~200MB)
- Download and install “Orwell Dev-C++ IDE” from here (~50MB)
This C++ IDE includes a stable compiler for C/C++ which we’ll use from NotePad++ to compile and run C/C++ code (you can also find and install some other variant of C++ compiler)
- No need to install Visual Studio, Windows comes with built-in .NET compiler 😎
- Install python from here (~25MB)
3.2 Setting PATH of Compiler in ‘System Variables’:
- Right click on
Computer -> Properties -> Advance System setting -> Environmental Variablesunder ‘System Variables’ find ‘Path’ and Click ‘Edit’:
- Now, append the Path of Compilers in ‘variable value’ field. Add paths at the end of the line (do not delete the existing text!)
- Before adding the paths please check the correct Path It may be different for your PC!
- Semi colon (;) symbol is important after the each path as It marks the end of the previous path so you can add a new one.
C:\Program Files (x86)\Dev-Cpp\MinGW64\bin;
Update: There is a direct way to add new paths in the latest update of Windows 10. Click on the ‘New’ button to add paths:
You can check these paths by opening CMD and typing gcc for C/C++, Java for java, csc for C#, python for Python (one at a time):
4. Copy Pasting script in Notepad++ folder:
- Open Run using
%appdata%and hit enter.
- Now navigate to
Notepad++ -> plugins -> configfolder in PC.
- Download NppExec script and extract files in config folder (replace NppExec.ini).
5. Set shortcut:
This is the final step ( I promise 😛 ) to set the desired shortcuts in Notepad++.
- Go to
Settings-> Shortcut mapper.
- Select Plugin commands and scroll to the bottom of the list.
- There you can set the desired shortcuts for scripts.
That’s all folks!
Now you can create a new file in Notepad++
CTRL+N for writing code of
Python or open an existing code file and compile/run with your shortcuts. Make sure to save the file with proper extension like .c / .cpp / .cs / .java /.py instead of .txt
Complete repository of NppExec scripts can be found here:
Currently, this script support C, C++, Java, C# and Python Language. Comment below and let us know if you want support for any additional language 🙂