Fine-Tuning the ‘vim-project’ Plugin for My Perl Needs

Oct 21, 2012 / By Yanick Champoux

Tags: ,

I’m a vim man. Sure, from time to time, I hit mid-line editing crisis and feel the need to go and try out some other more flashy editors. But so far, I’ve always returned to dear ol’ Vim.

Of course, when it comes to hacking code, it comes in handy when the editor can also give you a view of the overall project. To browse directories, I’m using the NERD Tree. But I also like to have a view where I can move files around in the listing, organize them in categories, and hide a few of them. For that, there’s vim project. It’s cool, it’s nifty, it’s…almost what I want. Because you see, refreshing your view throws away all manual changes, so the user is caught between adding new files manually (booh!) or having to reorganize things each time ‘refresh’ is hit (gah!).

Obviously, something has to be done about that. I created a small script, gen_pvim.pl, which updates a project.vim with new files (and new ignores) or creates a skeleton one where none is present:

$ gen_pvim
Dancer-Plugin-MobileDevice=/home/yanick/work/perl-modules/Dancer-Plugin-MobileDevice CD=. {

lib/                 Files=lib {
Dancer/Plugin/MobileDevice.pm
}
t/                   Files=t {
01-is-mobile-device.t
boilerplate.t
pod-coverage.t
manifest.t
03-dynamic-layout.t
02-tokens.t
00-load.t
logs/development.log
pod.t
views/layouts/main.tt
views/layouts/mobile.tt
views/index.tt
}
distro               Files=. {
MANIFEST
.gitignore
Changes
Makefile.PL
MANIFEST.SKIP
ignore.txt
README
}
# \.git
}

When updating a project.vim file, this script will insert any new file (in the right folder, natch) and will take any comment as regex for files that must be ignored. For bonus points, the ignore filters are localized to their folder and their descendants.

As the final touch, I slightly modified ‘vim project’ so that it would refresh the project listing using my little script. Oh, and I defined a bash alias:

$ alias pvim
alias pvim='gvim +'\''Project project.vim'\'''

The result? Not yet a perfect IDE, but it’s getting closer…

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>