notepad++ Useful plugins for developers NppExec


NppExec [sourceforge] allows you to execute commands and scripts from a console window in Notepad++. It can be found in the menu bar at Plugins -> NppExec or just by simply hitting the F6 key (the shortcut Ctrl+F6 will run the latest command) .

Example: the following will

  • Set the console to output_var: on, meaning we can use the output of the console
  • run a SQL query from the file C:\scripts\query.sql
  • take the output from the console and put it into the active file at the cursor
  • close the console
  • clear the console
sqlcmd -S -U UserName -P "password" -i C:\scripts\query.sql
sel_settext $(OUTPUT)

NppExec also allows you to save your scripts. After saving them, you can go to Plugins -> NppExec -> Advanced Options and run it anytime Notepad++ starts, closes, or even add that script to the Plugin commands using Macros. For example, by saving the above example as a "Run Query", I could use the bottom left fields in the Advanced Options to add it to the menu.

Add to Menu

The script will be available as a macro after a restart of Notepad++ as long as the "Place to the Macros submenu" box is checked.

Finally, a shortcut can be assigned to the macro/command by using Settings -> Shortcut mapper -> Plugin commands.