Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6057377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:28:54+00:00 2026-05-23T08:28:54+00:00

I want to teach Vim how to open Perl 5 modules from names like

  • 0

I want to teach Vim how to open Perl 5 modules from names like File::Find. I already have a wrapper script written in Perl 5 that handles the commandline (see below), but I would like to be able to say things like :tabe File::Find and have it really execute :tabe /home/cowens/apps/perlbrew/perls/perl-5.14.0/lib/5.14.0/File/Find.pm.

My current plan is to somehow use autocmd BufNewFile and/or autocmd BufPreRead, but I can’t figure out how to switch the file name.

#!/usr/bin/perl

use strict;
use warnings;

my @files = @ARGV;
for my $file (@files) {
    next if -f $file; #skip files that really exist

    #convert from module name to module file
    (my $module = $file) =~ s{::}{/}g;
    $module .= ".pm";

    #look for module in the include paths
    for my $dir (@INC) {
        my $candidate = "$dir/$module";
        if (-f $candidate) {
            $file = $candidate;
            last;
        }
    }
}

#replace this script with vim
exec "vim", "-p", @files;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:28:55+00:00Added an answer on May 23, 2026 at 8:28 am

    Doing

    :verbose au BufReadCmd
    

    Will tell you how other types of plugins do this (e.g. zip, netrw, fugitive). Sample output that should give you plenty of ideas:

    zip  BufReadCmd
        zipfile:* call zip#Read(expand("<amatch>"), 1)
        Last set from C:\Program Files\Vim\vim73\plugin\zipPlugin.vim
        *.zip     call zip#Browse(expand("<amatch>"))
        Last set from C:\Program Files\Vim\vim73\plugin\zipPlugin.vim
    
    Network  BufReadCmd
        ftp://*   exe "silent doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(expand("<amatch>"))
        Last set from C:\Program Files\Vim\vim73\plugin\netrwPlugin.vim
        http://*  exe "silent doau BufReadPre ".fnameescape(expand("<amatch>"))|call netrw#Nread(2,expand("<amatch>"))|exe "silent doau BufReadPost ".fnameescape(expand("<amatch>"))
        Last set from C:\Program Files\Vim\vim73\plugin\netrwPlugin.vim
    
    fugitive_files  BufReadCmd
        *.git/index
                  exe s:BufReadIndex()
        Last set from C:\Program Files\Vim\vimfiles\plugin\fugitive.vim
        *.git/*index*.lock
                  exe s:BufReadIndex()
        Last set from C:\Program Files\Vim\vimfiles\plugin\fugitive.vim
        fugitive://**//[0-3]/**
                  exe s:BufReadIndexFile()
        Last set from C:\Program Files\Vim\vimfiles\plugin\fugitive.vim
        fugitive://**//[0-9a-f][0-9a-f]*
                  exe s:BufReadObject()
        Last set from C:\Program Files\Vim\vimfiles\plugin\fugitive.vim
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using MVVM and want nothing in the View's C# file. We have
I want to have a way to teach hudson to delete the complete workspace
I have been trying to teach myself Lambdaj and it doesn't seem to want
I have retrieved some values from database. In my view file I have the
Let me explain. Suppose I want to teach Python to someone who only speaks
I'm basically trying to teach myself how to code and I want to follow
I have an application used by pretty tech-savey people and they want small island
want to know why String behaves like value type while using ==. String s1
want to have a Hyperlink-Button in a gridView in which I can display a
I am trying to teach myself Python, and I have realized that the only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.