-1

I'm trying to code in C++ using Notepad++. As far as I know, Notepad++ needs to have scripts compiled by an external compiler (if this is not true please let me know) so I'm looking at using Eclipse IDE to compile the code. How do I set it up in Npp so that when I click run, it compiles in Eclipse?

If I'm missing some big part of the setup for a project, please let me know because this is all from scratch.

1
  • You really shouldn't.. use Eclipse or use Notepad++ with something like NppExec
    – Insane
    Dec 2, 2015 at 5:27

1 Answer 1

4

While really it doesn't make sense to do it this way (use a proper IDE like eclipse), it is possible using NppExec. Note that many IDEs allow you to set up an external text editor if you prefer to use Notepad++, while still allowing you to use the IDEs integrated toolchains for building/testing.

You basically set up a script to run to do the compiling and NppExec will execute the commands - including calls to external programs like cmd.exe.

This is what I've used in the past to quickly test code using gcc that was installed as part of Cygwin (needs to be on the system path in this example), but you can modify it for other compiler paths:

cls
echo Deleting old version of: $(NAME_PART).exe (If Exists)...
cmd /c del "$(CURRENT_DIRECTORY)\$(NAME_PART).exe"
echo Saving Notepad++ File ($(FULL_CURRENT_PATH))...
NPP_SAVE
echo
INPUTBOX "GCC Compiler Switches. Add switches here, or press enter to use default. Output file will be $(NAME_PART).exe":  
echo Compiling Program...
cmd /c "gcc -std=gnu99 "$(FULL_CURRENT_PATH)" -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" $(INPUT)"
echo $(OUTPUT)
echo Exit Status: $(EXITCODE)

You can modify it to suit your needs. Basically it starts by deleting any .exe with the same name and in the same directory as the current file (this is the file that GCC will be instructed to output once compiled). You can skip this if preferred.

Then it saves the current file open in Notepad++.

Next it displays an dialog message to enter any additional switches for GCC.

It then calls GCC to compile the current file and produce an .exe with the same name.

2
  • So in your opinion, I should use the IDE by itself? I'm open to any method, and I was confused as to the abilities of Notepad++. Dec 2, 2015 at 6:18
  • @UnixCurious correct. Use the IDE itself. Notepad++ is a wonderful text editor, not a development environment. You can use N++ to edit your source files if you prefer it, and then eclipse to do the compiling/testing. Dec 2, 2015 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .