6

I can use :shell to enter current dir and run commands. bash_completion work fine.

But how get bash_completion working in :! command or :r ! command case?

Note. I am Emacs user and Emacs M-! command don't allow such things (also M-x shell, you need M-x term to get bash_completion).

tshepang
  • 12,111
  • 21
  • 91
  • 136
gavenkoa
  • 45,285
  • 19
  • 251
  • 303

2 Answers2

2

It is not possible. What @Prince Goulash is referring to is a simple filename completion done by vim itself. If you know how to force bash to pipe completion variants somewhere you can create a completion function for custom command which may in turn call built-in :!, but redefining completion for built-in commands is not possible.

I personally do not know how to do this with bash and know that trying to do so in zsh results in dirty hacks with redefining zsh built-in commands (like compadd), using pexpect (python), Expect (perl), expect (tcl), zsh/zpty or something similar to run shell in interactive mode and inventing zsh->vim IPC mechanism (in opposite direction it is much simpler) (I once started working on a similar module for zsh, but stopped as there were too much problems on this way).

ZyX
  • 52,536
  • 7
  • 114
  • 135
1

Have you got

set nocompatible

in your .vimrc? This automatically enables ex-mode completion for :!. To see the list of possible completions you could also use

set wildmenu

and investigate the wildmode options.

Prince Goulash
  • 15,295
  • 2
  • 46
  • 47