Make "Run.." Window keep the text entered in textbar after closing Notepad++
I love programming Python in Notepad++ but something i don’t love is having to select the path of the file every time i close Notepad++ as i made a batch file that gets the filename of my current file in Notepad++ and runs it
Is there a way to make Notepad++ use a saved run shortcut as default or just make it not clearing the Textbox so i don’t have to enter the filepath every time i reopen Notepad++?
It would probably help if you could describe a bit more this workflow you only hint at. Then there could be alternate solutions rather than just the one you’ve requested. Walk us through what you do and I’ll be a good solution comes out of it.
Stefan Huus Gregersen
There is. Creating a shortcut so you press CTRL + F5, but that is just annoying when the function is already in the software. I’d rather know the solution that makes the textbox not clearing when opening the software again .
I hope that the developers of notepad++ sees this and implement so it never clears the textbox when reopening the software
Well…I meant describe more of your overall workflow…you hint at Python and a batch file (which somehow gets the name of your N++ current file)…but to offer up solutions–to your generic problem, not necessarily your very specific one–more details are needed.
However, since you seem to be fixated on “gotta have the Run box keep the text over Notepad++ runs”, no one can offer up much (unless someone has an exact cure for that…anyone?) in the form of a “adjust your workflow” type solution, which may in fact lead you to think, “Why was I ever doing this with the Run box anyway?”.
But I understand that you want what you want. So I will kindly point you to the proper way to make feature requests for Notepad++ and that is here.
Well let me explain then
I got a file located at D:\Python_scripts\notepad++runfile\runPythonScript.bat
What it does is it receives an argument that is given when running the bat file
for example. runPythonScript.bat “C:/MyPythonScript.py”
Then it takes that argument and run python inside that exact same Window (py C:/MyPythonScript.py)
And then when my Python script crashes it has a “pause” in the batch file so i can see the error
And the argument that i use comes from the Notepad++ “$(FULL_CURRENT_PATH)” function that you can use which gives you the exact path of the current open file in Notepad++
Pressing the run button in Notepad++ with " D:\Python_scripts\notepad++runfile\runPythonScript.bat “$(FULL_CURRENT_PATH)” " written in the textbox
Bat file opens
It gets the filepath of the current open file in Notepad++ from “$(FULL_CURRENT_PATH)”
Then opens the python file by writing py (and then the path that it receives)
Now my Python script crashes
Then it pauses the bat so it wont continue so i can read the error that occured
Does that help you understand what i am doing? :)
Thanks for the recommendation of the “Feature request” but it kinda seems to be locked so i can’t use it hmm…
Okay, so there are many approaches to this…and probably @PeterJones is better at this than I am…but perhaps the very simplest is to Save your Run box command (D:\Python_scripts\notepad++runfile\runPythonScript.bat “$(FULL_CURRENT_PATH)”), giving it a name ("Python Run Current File"…?)and possibly a keycombination.
This has the added benefit of chopping 1 step off at run time…with your existing approach you are presented with the Run box and you have to OK it…with the above approach that is skipped.
Of course, this may be what you meant above when you were talking about “CTRL + F5”, but I don’t see why saving the command (which never changes) would be objectionable…
I am currently using the CTRl + F5 method but it just sucks using it when most of the software that i use for programming uses just F5 to execute
I know it actually is more inefficient doing F5 only than CTRL + F5 because of the dialog window but i also just find it more… Standard to do the F5
Yeah, you said everything I was working on for my response, but much more succinctly.
As for “the “Feature request” … seems to be locked”. Yes, the FAQ thread is locked. But as the text of the FAQ itself says, this forum is not the place for feature requests. The place for feature requests is linked in that FAQ. So follow that link, and you can make your feature request there.
Thanks for the additional details: it helped Scott give an excellent response. I had been writing my response assuming that you didn’t know about the
"$(FULL_CURRENT_PATH)", so I appreciate that you posted that update, so I wouldn’t waste your time with things you already knew.
You might also consider the NppExec plugin (available using that link, or thru the plugin manager), which was mentioned in @Claudia-Frank’s link, and would allow you to build a batch file that gets run in a pane of the Notepad++ GUI, rather than spawning an external
cmd.exewindow. That gets rid of the need for the “pause” and “hit any key…”, because it gets captured into an interactive sub-window of NPP.
Oh, i see your update. If you want F5 to be run-current-file, you can just edit the shortcuts.
** Settings > Shortcut Mapper > Macros > Run With Python** (or whatever you named your shortcut before): change it to
F5. Before you hit OK, it will say “conflict found”, and below will say something like “Main Menu | 269 Run…”. Make note of that, then hit OK. Go to the Main Menu tab, and replace the normal Run shortcut with Ctrl+F5. Swap complete, F5 will do what you want.
Stefan Huus Gregersen
Pretty good answer! I’d guess that is the closest i would get unless sending a request to add it in as a “feature”