Run Commands from Notepad++ with NppExec Plugin

Notepad++ is really great for editing source code files. But when you want to compile these source code files, you have to switch to another window. For example, if you are writing a C++  program, then you have to test it by switching to a command prompt window and running the compiler (e.g., g++).

But with the help of a Notepad++ plugin NppExec, you can run any commands or external programs right from within the Notepad++ window. The output and the exit codes from these commands are displayed in the Notepad++ window itself.

There are two ways using which you can install NppExec in Notepad++:

1. Install manually by downloading the plugin

  1. Download the latest version of NppExec plugin from https://github.com/d0vgan/nppexec. For Notepad++ versions 7.6 and higher, download the plugin file with PA in the filename, for example, NppExec_07_dll_x64_PA.zip. If you have installed 64-bit version of Notepad++, then download the file with x64 in the filename.
  2. Open the folder where you have installed Notepad++. Typically, it is C:\Program Files\Notepad++\.
  3. Extract all the contents of the downloaded ZIP file in step 1, into the plugins sub-folder inside the Notepad++ installation folder.NppExec
  4. Restart Notepad++ and you have NppExec ready.

2. Install through the Plugins Admin

  1. Launch Notepad++ and select PluginsPlugins Admin from the menubar.
  2. In the Plugins Admin window select select the Available tab.
  3. Select the NppExec plugin from the list of the plugins and then click on the Install button.NppExec
  4. Restart Notepad++ and you have NppExec ready for use.

There is one difference between these two methods – in the first method (manual), you get the latest version of the plugin. While in the second method through the Plugins Admin, you get a bit old version of the plugin. As you can see above, Plugins Admin installed NppExec 0.6 while version 0.7 is available on GitHub.

Run commands in NppExec Console

Once we have installed the NppExec plugin, we can access it from the menubar from under the Plugins. It offers many features such as running NppExec scripts and viewing the console window. It also comes with a help file that describes all the supported commands in detail.

NppExec

We can toggle the NppExec Console using the hotkey Ctrl ~. In the console, we can give the various supported  commands including running the compilers. For example, if you want to compile a C++ source code file hello.cpp, you can give the command g++ hello.cpp -o hello.exe. Of course, the g++ command path should be in the PATH variable of Windows system.