I have a command line tool that requires three parameters in the form of:command input1 input2I'm trying to write a custom complete function that handles completion for different arguments... well, differently.Determining which argument I'm on and returning a different set of completion options isn't hard; I've got that figured out:function! CustomCompletion(argLead, line, pos)   let argList = split(a:line)   if     len(argList) == 1       Do completion for arg 1 (the command)   elseif len(argList) == 2       Do completion for arg 2   elseif len(argList) == 3       Do completion for arg 3   endifendfunctionMy problem is with the argLead variable. :h command-completion-custom says this:ArgLead: the leading portion of the argument currently being  completed on.Places Iv'e researched seem to imply that this variable contains the current white-space separated argument that the cursor is on. However whenever I use it, the variable contains the whole command line (spaces and all). Additionally when I press tab after say, the second argument, the tab completion tries to match the whole command line instead just the current argument.Is there some way to tell the completion function to parse args based on white-space?Oh, and I'm calling this function in the thrid paramater of input() if that makes any difference.let user = input(Enter a command\n, , custom,CustomCompletion)Thanks
Using multiple arguments with custom tab completion
autocompletion
I believe that saginaw is correct. The problem resides in the fact that input() handles completion differently than the command! function. I don't think that the author of the input() function gave much thought to custom completion and only added partial support for it. As saginaw mentions, the intput() function has no -nargs parameter like command!. As a result the ArgLead parameter will always be the whole command line, and consequently the match will always be performed against the whole command line.Workaround:One possible solution is to prepend the previously typed arguments for completion. That way when the match is performed it will at least be able to see that the user input matches the predefined completions. I accomplished this in this way:function! CustomCompletion(argLead, line, pos)   let argList = split(a:line)   let returnString =    if     len(argList) == 1       This is the first argument so nothing special here   elseif len(argList) == 2       Second argument needs to add first argument to completion      for item in myCompletionList         let returnString .= argList[0] .   . item . \n      endfor      return returnString   endifendfunctionThis does work reasonably well. The drawback is that if you have windmenu set, the suggestions include the whole command line which is kind of annoying and hard to see if you have a lot of items.Example:At present I see no other alternatives, so this will have to do.As far as the other issue that saginaw mentioned, that is solved (as he stated) here. However, I didn't include it in the code since I didn't think it was relevant to the current problem and would just clutter the example.