Contents

Vim Snippet to Generate Package Name From The Filename

Contents

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 vim plugin it is 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. :)