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 9212887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:37:34+00:00 2026-06-18T01:37:34+00:00

I wrote a script analyzing perl-files (totally without PPI, because it will be used

  • 0

I wrote a script analyzing perl-files (totally without PPI, because it will be used on Servers where the admins don’t want PPI to be installed and so on and so forth, but let’s not talk about that).

Now, let’s say I have this code:

my $object = MySQL->new();
my $ob2 = $object;
$ob2->    

(Where MySQL is one of our modules).
My script correctly identifies that $ob2 is a MySQL-Object and sees where it came from, and then returns a list of found subs in that module.

My idea was, that, since I use vim for editing, this could be a really cool way for “CTRL-n”-Completetion.

So, when…

$ob2->[CTRL-n]

It shows the CTRL-n-Box which opens my Perl-Script and gives it a few parameters (I would need: The line that I am actually on, the cursor position and the whole file as it is in vim).

I already found things like vim-perl, which allows me to write something like

if has('perl')
    function DefPerl()
perl << EOF
    use MyModule;
    return call_to_my_function(); # returns all the methods from the object for example
EOF
    endfunction
    call DefPerl()
endif

But somehow this does not get executed (I tried writing something to a file with a system call just for the sake of testing)…

So, in short:

Does anyone here know how to achieve that? Calling a perl-function from vim by pressing CTRL-n with the full file-code and the line vim is actually in and the position, and then opening a completetion-menu with the results it got from the perl-script?

I hope someone knows what I mean here. Any help would be appreciated.

  • 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-06-18T01:37:35+00:00Added an answer on June 18, 2026 at 1:37 am

    The details and tips for invoking embedded Perl code from Vim can be found in this Vim Tips Wiki article. Your attempts are already pretty close, but to return stuff from Perl, you need to use Vim’s Perl API:

    VIM::DoCommand "let retVal=". aMeaningfullThingToReturn
    

    For the completion menu, your Perl code needs to return a List of Vim objects that adhere to the format as described by :help complete-items. And :help complete-functions shows how to trigger the completion. Basically, you define an insert-mode mapping that sets 'completefunc' and then trigger your function via <C-x><C-u>. Here’s a skeleton to get your started:

    function! ExampleComplete( findstart, base )
        if a:findstart
            " Locate the start of the keyword.
            let l:startCol = searchpos('\k*\%#', 'bn', line('.'))[1]
            if l:startCol == 0
                let l:startCol = col('.')
            endif
            return l:startCol - 1 " Return byte index, not column.
        else
            " Find matches starting with a:base.
            let l:matches = [{'word': 'example1'}, {'word': 'example2'}]
            " TODO: Invoke your Perl function here, input: a:base, output: l:matches
            return l:matches
        endif
    endfunction
    
    function! ExampleCompleteExpr()
        set completefunc=ExampleComplete
        return "\<C-x>\<C-u>"
    endfunction
    inoremap <script> <expr> <Plug>(ExampleComplete) ExampleCompleteExpr()
    if ! hasmapto('<Plug>(ExampleComplete)', 'i')
        imap <C-x><C-z> <Plug>(ExampleComplete)
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently optimizing and maintaining a Perl script used to analyze two CSV files
i have wrote a script to produce an array of data but now want
I wrote a script for some text manipulation, and want to add a function
I wrote a script in php which reads two files and takes all the
I wrote Python script that processes big number of large text files and may
I wrote a script that takes in two files ending in .cfg and outputs
I wrote this script to find all files/directories to which $WWWUSER has write permissions.
I wrote this script to automate wgets from my different servers, between each other,
I wrote a script that collects all our log files to one tar file.
I wrote this script but it only works if I don't ad class=yes ,

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.