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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:54:43+00:00 2026-05-24T11:54:43+00:00

Is there a way to achieve the following in Vim? command! -nargs=* -complete=customlist,CustomFunc1 -complete=customlist,CustomFunc2

  • 0

Is there a way to achieve the following in Vim?

command! -nargs=* -complete=customlist,CustomFunc1 -complete=customlist,CustomFunc2 Foo call MyFunction(<f-args>)

The user will be able to tab-complete two arguments when calling the function Foo from Vim command line. The auto-complete will pull from two different lists.

E.g.:

:Foo arg1 good<TAB> whi<TAB>

Pressing Tab completes the words:

:Foo arg1 goodyear white
  • 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-24T11:54:44+00:00Added an answer on May 24, 2026 at 11:54 am

    There is sufficient information passed to completion function through
    its arguments. Knowing current cursor position in the command line to
    be completed, it is possible to determine the number of the argument
    that is currently being edited. Here is the function that returns
    that number as the only completion suggestion:

    " Custom completion function for the command 'Foo'
    function! FooComplete(arg, line, pos)
        let l = split(a:line[:a:pos-1], '\%(\%(\%(^\|[^\\]\)\\\)\@<!\s\)\+', 1)
        let n = len(l) - index(l, 'Foo') - 1
        return [string(n)]
    endfunction
    

    Substitute the last line with a call to one of the functions
    completing specific argument (assuming they are already written).
    For instance:

        let funcs = ['FooCompleteFirst', 'FooCompleteSecond']
        return call(funcs[n], [a:arg, a:line, a:pos])
    

    Note that it is necessary to ignore whitespace-separated words before
    the command name, because those could be the limits of a range, or
    a count, if the command has either of them (spaces are allowed in both).

    The regular expression used to split command line into arguments takes
    into account escaped whitespace which is a part of an argument, and
    not a separator. (Of course, completion functions should escape
    whitespace in suggested candidates, as usual in case of the command
    having more than one possible argument.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an easier way to achieve the following? var obj = from row
Is there a way of achieve the following transformation in the BT mapper? if
is there any way I can achieve the following in scala with new Car()
Is there a way to achieve the following? In my /www/var/public_html/index.php file i have
Is there a way to achieve the following in one line ? : if
is there a simple css way to achieve the following layout?: here you can
Is there a clever way to achieve the following in Ruby? hash1 = {
Is there a way to achieve this in pydot? Take the following example: [Outputted
Is there any way to achieve function overloading in C? I am looking at
I would like to ask is there any way to achieve this functionality: I

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.