Personal and technical blog and information site

Setting Up Notepad++ as a Compiler

Getting set up

  1. Download and install Notepad++ from
  2. Open Notepad++ and select Plugins -> Plugin Manager -> Show Plugin Manager from the header menu.
  3. Once the list populates, find NppExec in the list of available plugins, check the box next to it, and select Install. Wait for the download to complete and accept all prompts.

Configuring NppExec for Java

  1. If you have not already done so, install Java SE Development Kit now from Oracle. This will provide javac.exe which compiles java code. Restart your computer after this installation to enforce new environment variables.
  2. If NppExec installed successfully, you should see the menu option Plugins -> NppExec -> Execute..., select it now.
  3. Type the following in the input box:
    javac.exe $(FILE_NAME)
    This will save your current document, make sure the current directory of the program is the current directory of your file, and then execute the javac compiler on your file.
  4. Next, select Save, enter a name such as "Compile Java" and then select Save again.
    If you have a Java source file open now, try running this script by going to execute again and running the script.

    If javac.exe is not found you may need to provide the full path to javac. This is located in the "Program Files" folder under your primary (operating system) storage drive in most circumstances. For example: C:\Program Files\Java\jdk1.8.0_60\bin\javac.exe.
  5. You will want to be able to run your code as well, so we will create an additional script the same way we did the last one, calling it "Compile and Run Java".
    javac.exe $(FILE_NAME)
    java.exe $(NAME_PART)
    Again, if javac.exe or java.exe aren't automatically found you need to place the absolute paths here instead.

Downloading The C Compiler

  1. If you have not already done so, download a C or C++ compiler. For this tutorial I will be demonstrating with MinGW, but other compilers such as Microsoft Visual C++ and Bloodshed Dev C++ have similar compiler parameters. If you have a compiler set up that you know how to use, please skip this section.
  2. Download MinGW-Get from SourceForge. This program is a Windows alternative to Linux-style repository software management just for MinGW... and it's a huge pain if you're not used to it.
  3. Install MinGW-Get. There is no need to install any shortcuts but you should install near the root of a drive, or at least at a path with no spaces.
  4. Open your preferred command line interface (such as Command Prompt) and navigate to your MinGW folder, then navigate to the bin folder inside.
    Execute the following to install the g++ compiler: mingw-get.exe install g++
    Wait for the installation to complete.

Configuring NppExec for C

  1. Open Plugins -> NppExec -> Execute and add another script. I called this one "Compile C" since g++ will compile both C and C++.
  2. Setting up the C compiler doesn't look as clean as the Java compiler. For some reason MinGW demands the current directory be its own program directory, so as shown below, the first step is to move focus to the MinGW folder. Modify the path C:\MinGW\bin\ to match your installation directory.
    cd "C:\MinGW\bin\"
    g++.exe -static "$(CURRENT_DIRECTORY)\$(FILE_NAME)" -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe
    The references to NppExec variable CURRENT_DIRECTORY are allowing us to direct the compiler to the path of our file since we are no longer working in that directory. Like I said... Java was much nicer! Play with the compiler options to best suit your needs. Remember to save!
  3. Now add another script. I named this one "Run EXE" since it runs any EXE in the current directory that matches your source file's name. You could prepend a compile operation by copying the script above, but this script could run code generated from other languages, so I chose to leave it separate.
    This script should not require modification.
  4. Simply create macros for these following the same directions as before. Your compile script should generate an EXE, and the run script should, well, run it. If that doesn't happen, you've got a problem. As a side-note, I noticed that g++ will actually hand java files off to the java compiler if you try to compile them. I haven't tested it, but running multiple formats through g++ may allow for fewer hot-keys. If you have any luck with that please feel free to post in the comments.

Configuring fast macro hot-keys

  1. Navigate to Plugins -> NppExec -> Advanced Options
  2. Make sure the "Place to the Macros submenu" is checked.
  3. In the lower left, select the script you wish to create a macro for, and provide a name for the macro. I named my macros identical to my scripts for the sake of simplicity. This step translates the plugin's script to something Notepad++ can execute as a macro. Select add/modify and your item should appear in the list above. Repeat this for all scripts you want to access with a macro.
  4. Select the Macro menu on the header bar, and your new macros should now be at the bottom. If they are not, make sure you saved your macros and checked the box in the previous steps.
  5. Open the shortcut mapper with Macro -> Modify Shortcut/Delete Macro and go to the Plugins tab. Here you should be able to find your custom macros and assign keys to them. I prefer F5 to compile Java, F6 to compile and run, and F7 and F8 to do the same for C. If keys are already taken, find which macros are using them and switch them out or remove them.
  6. Try pressing the hot-keys and see if your code compiles and runs. If it does not, walk through the steps again or troubleshoot by removing plugins that may be incompatible with NppExec or the use of macro function keys.


Unfortunately there are drawbacks to using a light-weight IDE alternative.

First of all, Notepad++ does not provide intellisense-like features or anything more than rudimentary word suggestions. Additional plugins may be able to handle such functionality.
Customizing the C compiler and linker arguments is difficult, which makes large projects painful if not impossible to configure. It is my firm belief that the code itself should contain all information the compiler needs to locate and use dependencies, but unfortunately most languages do not work that way. In my experience, Java is by far the best at this, allowing relative and absolute paths to dependencies. However, C is defiant, and will probably react by deleting your homework assignments just for spite.
Written By: Erik W. Greif
Published: 2015.12.26 16:52PST
Modified: 2015.12.26 20:03PST
Article Title: Setting Up Notepad++ as a Compiler
Article URL:
Website Title: Bit Fracture Online
Website URL:
Media Type: Blog Post/Technical Article
View full citation

Technical Articles

Select an article title to view its full contents.