tags:

views:

1823

answers:

1

Hello. 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..

+2  A: 

You need to put the file name at the end of the command. In the Run(F5) dialog, try this:

runscript $(FULL_CURRENT_PATH)\$(FILE_NAME)

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
akf
In the current Notepad++ version `$(FULL_CURRENT_PATH)` already contains file name.
Semyon Perepelitsa