I want to make notepad++ run the "ruby {filename_here}" command if the current filename ends with .rb and "perl {filename_here}" if it ends with .pl. I've tried to use the NppExec plugin, but it can't do conditional stuff, so I wrote a bat
@echo off
if /i %~sx1 == .pl perl "%~f1"
if /i %~sx1 == .rb ruby "%~f1"
if /i %~sx1 == .php php "%~f1"
Now I can use it from the command line like C:\Program Files\Notepad++>runscript "D\pl.pl" and it works fine. Now how can I bind some key in Notepad++ to "runscript $(FULL_CURRENT_PATH)"? I've tried to use the Run->Run menu (F5), but it doesn't seem to work..
Run -> Run (F5) Type command line into "The Program to Run" Save, type the name (choose the shortcut if you need)
How to run CMD console commands in Notepad++ If you want to work with Notepad++ and CMD (Command Line) Console at once you can install NPPExec plugin. Once you install this plugin using Plugin Manager, go to Plugins -> NppExec -> Execute..., or press F6 key.
To run a script using the default engine:Double click the script in Windows Explorer or on the desktop. Click Start, select Run, and enter the script name. On Windows NT and Windows 2000 only, simply enter the script name on a command line.
You need to put the file name at the end of the command. In the Run(F5) dialog, try this:
runscript $(FULL_CURRENT_PATH)
If you want to test it out, you could put a & pause
at the end, just to see if it worked.
You could also tweak your script a bit so that every file doesn't test for each extension, by using the dreaded GOTO
command with file extension labels:
@echo off
GOTO %~sx1
:.pl
perl "%~f1"
GOTO end
:.rb
ruby "%~f1"
GOTO end
:.php
php "%~f1"
GOTO end
:end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With