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

Bothls include/ tab andls include/et_co tabdo 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 

Other example

If you don't have access to edit files or add archives to /etc. You can add local completion, for example for wp-cli you can dowload the completion definition and rename to hide the command:

wget
rename wp-completion.bash .wp-completion.bash

Now edit your .bash_profile using nano .bash_profile or vimadding this:

source /home/tu_usuario_del_host/.wp-completion.bash
7

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like