Flux
Flux

Reputation: 10950

Vim autocompletion in terminal mode

When in insert mode, a list of completion candidates can be shown by pressing Ctrln (for insert mode completion), or CtrlxCtrlo (for Omni completion when omnifunc is set). However, these keybindings do not work in terminal mode (:term).

Question: how can I get a list of completion candidates when in terminal mode? I was expecting to be able to make vim display completion candidates like grep, kill, cd, python3, and file paths like /home/user/Desktop, /home/user/Documents, etc.

I am using vim 8.0.

Upvotes: 2

Views: 2562

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172758

A :terminal is just a view into an interactive shell (or another command started by or in place of the shell). Vim offers some integration (pass on typed keys, show output), but it's the shell who's running the show.

As Vim does not know what's going on there (you could have launched a command where completions for file system paths or commands, as you've suggested, would not make any sense; you could have ssh'd into another system that does not have python3 installed), it cannot and should not offer you these things. Instead, as others have already commented, this is the job of the shell (and most of them provide completion, some (like Bash) even very powerful and extensible ones that go far beyond your suggestions) or the command that is running.

Upvotes: 0

B.G.
B.G.

Reputation: 6036

In this case a terminal is shown in vim, so your input goes to the terminal not to vim. That means we have to use the completion your terminal offers you. tab should be working like always, for a vim style completion you could add that to your .inputrc:

# cycle forward
Control-n: menu-complete
# cycle backward
Control-p: menu-complete-backward

Upvotes: 0

Related Questions