Using Perl-Tidy with Notepad++

I was looking for a way to use Perl::Tidy with Notepad++ so I can format my Perl code from within Notepad++. Luckily for me someone else already figured out how to do this properly. I just had to modify a few small things to make this work for my needs.

My environment is a Windows Vista SP2 system with Strawberry Perl 5.12.1. Thanks to Strawberry modifying the system PATH I don’t need to configure this myself. After installing Perl::Tidy I can just call the perltidy command from the command-line. But for some reason calling the perltidy directly from within NppExec doesn’t work.

First, you need a .perltidyrc, or rather on Windows a perltidy.ini. I don’t really know why this has to be different, probably because it sometimes can be a pain to create a nameless file (meaning, a file with only a extension). Here’s my perltidy.ini file which I installed under C:\Users\<USERNAME>\perltidy.ini. I’ve actually shamelessly stolen this configuration from Mojo.

So following the earlier mentioned blog post this is what I changed to make it work for me.

  1. Change the command-line in NppExec to the following:
    perl -x -S perltidy "$(FULL_CURRENT_PATH)"
  2. Do the Advanced Options part
  3. Now create a Macro: for some reason this doesn’t work?

    1. Start recording
    2. Go to Macro > Execute your newly added perltidy macro
    3. Go to File > Reload from Disk
    4. Stop recording
    5. Save Macro and assign a shortcut to it

Now I wanted to be able to fire this off with a key shortcut, but I can’t add those to macro’s created with NppExec. So instead I tried to create a macro that executes the perltidy macro and then reloads the file from disk. But when executing this macro nothing happens. So if anyone has an idea to why this is I’d be glad to hear it.

For now this manual execution will work just fine. It’s just annoying that I’ll have to reload the file from disk manually.

Scroll to Top