Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile and run C files from within Notepad++ using NppExec plugin?

How can I configure the NppExec plugin for Notepad++?

I would like NppExec to compile my C files, run them, and show their output, all within Notepad++.

like image 885
Chris Smullian Avatar asked Mar 24 '10 09:03

Chris Smullian


People also ask

Can Notepad++ compile files?

You can now compile and run C++ programs from within Notepad++. To test the set up, copy the following program into a new Notepad++ tab and save the file as hello. cpp to a convenient location like the Desktop. Select C++ compile script from the dropdown list.


1 Answers

Here's a procedure for Perl, just adapt it for C. Hope it helps.

  • Open Notepad++
  • Type F6 to open the execute window
  • Write the following commands:
    • npp_save <-- Saves the current document
    • CD $(CURRENT_DIRECTORY) <-- Moves to the current directory
    • perl.exe -c -w "$(FILE_NAME)" <-- executes the command perl.exe -c -w , example: perl.exe -c -w test.pl (-c = compile -w = warnings)
  • Click on Save
  • Type a name to save the script (e.g. "Perl Compile")
  • Go to Menu Plugins -> Nppexec -> advanced options -> Menu Item (Note: this is right BELOW 'Menu Items *')
  • In the combobox titled 'Associated Script' select the script recently created in its dropdown menu, select Add/Modify and click OK -> OK
  • Restart Notepad++
  • Go to Settings -> Shortcut mapper -> Plugins -> search for the script name
  • Select the shortcut to use (ie Ctrl + 1), click OK
  • Verify that you can now run the script created with the shortcut selected.
like image 200
David Avatar answered Oct 09 '22 13:10

David