On 18/04/11 12:23 PM, Ted wrote:
Hello folks,
I've written a command that will replace the contents of a buffer with
the output of a shell command.
I'd like to have it provide completion as similar as possible to that
used by bash itself. Ideally, I would like it to use the bash
completions themselves, presumably by spawning a subshell. A fallback
(for compatibility, speed, or practicality) would be to use the same
sort of completion provided by vim's `:!` command. This seems to work
by doing command-name completion on the first word and filename
completion (and escaping) on subsequent words.
I have tried using `-complete=shellcmd`, but this only seems to
complete command names and does not progress to completing filenames
after the first word.
Vim's custom commands allow for context-sensitive completion if you use
the -complete=custom or -complete=customlist variants. It's a bit of
messing around, but it should be possible. I guess having a simple
choice to do completion the same way as for :! could be a feature
request, though.
I've also looked into hooking into bash to have it handle completion;
there does not seem to be a straightforward way to do this, either.
Here, the complications are due to what seems to be a lack of features
in bash itself, so any advice is likely somewhat off-topic, but
nonetheless welcome :)
I'm not sure how Vim itself does it, but I'm pretty sure it gets its
list of completions from the shell for the -complete=shellcmd option
(and completion for the :! command). So I guess there is some degree to
which this is possible. Maybe looking in Vim's source code or help would
shed some light on how this is done.
Is there an addon or a wiki page which provides such feature or a
recipe to implement it?
No idea, but it seems somewhat likely someone's tried something similar
before.
Ben.
--
You received this message from the "vim_use" 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