I knew Notepad++ could run programs and that I could just compile directly via command line from it, I had just been too lazy to set it up. I decided to make it work, and in researching how I found a lot of old info. I decided to explain the process I used here for future reference.
The first step is to acquire nppexec, which used to be bundled with Notepad++ but isn't any more. It comes as a zip of one dll and two folders, just put them all in the plugins folder of Notepad++.
Now you need gcc/g++. MinGW is the standard way of doing this on Windows. I went with this version because it came with a lot of useful libraries like boost. Just extract that to some path with no spaces (spaces may work, but are generally a bad idea), and run the batch file. You may need to add that path to the windows path system variable; I already had it in there from a past install of MinGW. At this point test the install by running: g++ --version in a command prompt. I have something like 5 versions of g++ floating around my computer, and it kept running an old version. I finally just deleted that one.
Now open Notepad++ and hit F6 to bring up the execute window. Here you can enter this code:
g++ "$(FILE_NAME)" -o $(NAME_PART) -march=native -O3
I'll explain what each line does, so you can edit it as you see fit. The first saves the current document. Next changes the directory to the one the file is in. Before this I kept compiling and couldn't find the executable. It was in the Notepad++ folder. Skipping the third for now, the last line runs the executable.
The third line does the actual compiling.
g++.exe "$(FILE_NAME)"should be clear, and
-o $(NAME_PART)is the output filename.
-O3uses the highest optimization level in g++. There is some debate online as to whether the 3rd level is more trouble than it's worth. A lot of people suggested that the 3rd was too aggressive, which could cause compile errors and is even sometimes slower than the 2nd level. This wasn't unanimous though, and there weren't any references to actual examples. Frankly, I felt like this was probably an example of cargo cult programming where it may have been true 15 years ago but people have just been repeating the same thing without ever stopping to reevaluate if it is still true. In my exhaustive test of two programs it produced a program that was the same as level 2 as far as I could tell.
-march=nativedetects which instruction sets (eg SSE) are supported by the system doing the compiling and enables any that are. This is a good option when the code will run on the same or similar system to the one compiling.
Anyway, once you have this code save it as something like 'Compile C++'. You could create a few versions here, like one that doesn't run the code after compile, or that uses different flags. I made one for interpreted languages that don't need compiling that is just:
At this point, you are almost done. Hitting F6 brings up that execute box where you can select which script to run. Hitting Ctrl+F6 runs the last ran script. However, I found hitting Ctrl+F6 to be annoying. So I decided to remap it to just F5 (leaving F6 to bring up the box). Under settings go to shortcut mapper. Under main menu scroll down and find the command currently mapped to F5 (the simpler run box), and change it to something else or nothing. Then under plugin commands find direct execute last, mapped to Ctrl+F6 and change it to F5.
That's it. The first time you hit F5 in a document it brings up the box to let you pick which script to run. Then every time after that it remembers and just runs it.