Christian J. Robinson wrote:

> >> My explanation is probably unclear, but I can reproduce it by 
> >> sourcing the attached file, typing ":Foo " and pressing tab (clear 
> >> away the blank confirm dialog), then pressing backspace to delete 
> >> the '1' and then pressing tab again.  The confirm dialog shows only 
> >> "bar" instead of "foo\ bar"/"foo bar".  Clearing away that confirm 
> >> dialog shows "foo\ foo\ bar1" on the command line.
> >
> > You also get the whole command line and the cursor position.  You 
> > can use that to figure out the whole completion.  Vim doesn't know 
> > that the thing being completed could continue before a space.
> 
> But that doesn't work either.  I can use the full command line to 
> figure out the whole completion and return the possible completions, 
> but Vim still inserts the new whole completion (with spaces) only in 
> place of the text after the last space--it does not replace the entire 
> text it should be replacing.

Vim doesn't know where the text to be replaced starts, thus you need to
give only the part that it expects.  You have to strip the first part,
which is identical in every returned item.

> Can I somehow tell Vim to replace the entire set of arguments after 
> the command itself during completion?
> 
> I really do think Vim should treat backslash-escaped spaces as being 
> part of a greater single argument.  As far as I can tell, as it is I 
> have no way of effectively dealing with spaces in arguments during 
> custom completion.
> 
> Perhaps Vim could be altered to do it more like what I want if a 
> command is defined with -nargs=? or -nargs=1 instead of -nargs=*?

It's impossible to do this correctly in all situations.  That's why it
is left to the completion function, because it's the place where the
desired behavior is known.

So yes, it's a bit more work to write the completion function if you
have arguments with spaces in it.

The 'completefunc' has a separate call to find the start of the
completed item.  That makes some things easier, but also makes it more
complicated for simple completions.

-- 
(letter from Mark to Mike, about the film's probable certificate)
      I would like to get back to the Censor and agree to lose the shits, take
      the odd Jesus Christ out and lose Oh fuck off, but to retain 'fart in
      your general direction', 'castanets of your testicles' and 'oral sex'
      and ask him for an 'A' rating on that basis.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui