vim snippet to generate package name from the filename

One thing that that had been particularly annoying me lately, was the ridiculously long package names called for in a certain project of mine. The package names themselves weren’t the problem, it was writing them out. With filenames like lib/App/MediaTracker/TemplateFor/Browser/PrivatePath/libraries/things/document.pm, the corresponding package names become very long and very painful very quickly.

Fortunately, I use vim as my editor of choice. Along with the fantastic snipmate vim plugin it’s possible to create a snippet that runs a little vim code as part of it:

The snippet should be stored in ~/.vim/snippets/perl.snippets, unless you have things arranged otherwise.

Now, assuming that my filename and package name are the typical parallels, simply typing pkg<tab> will create a proper package line for me, with an absolute minimum of pain. :)

One thought on “vim snippet to generate package name from the filename”

Leave a Reply