Autocomplete of File Path Does Not Work After "Vim" in Terminal

Steps to reproduce

git clone 
cd vecterion_vge
  1. input vim include/ tab
  2. input vim include/et_co tab

What I expected to see

  1. show file list in include/
  2. autocomplete file path vim include/et_color_panel.h

What I saw instead

Both 1. and 2. do not work.

Other

Both ls include/ tab and ls include/et_co tab do work.

The input vim vecterion_vge/include/et_co tab on parent directory (home dir) does work.

How can I fix this?

4

1 Answer

Maybe you turned off the completion specifications associated with vim.

complete -p vim

And check the output:

complete -F _filedir_xspec vim

If is something like the previous line, run the command:

complete -r vim

In general, and not directly related to vim you can follow these examples, modify for your case:

First example

You can list all the current completion routines active for your user via complete -p or list all the completion included in your system: ls /etc/bash_completion.d/

Completion is drived by the file /etc/bash_completion and new completion commands may be placed inside the directory /etc/bash_completion.d

You need to enable smart completion, editing your /etc/bash.bashrc file. I think you have, because the cd Tab completion. Anyway uncomment the following lines, by removing the # in the beginning of the lines:

#if [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
#fi

As you can see, everything depends on the information inside bash_completion.d file.

If you can even extend bash smart completion to your vim or apt need to edit /etc/bash_completion and /etc/bash_completion.d 

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.