Autocomplete of file path does not work after "vim" in terminal
Emily Wong
Steps to reproduce
git clone
cd vecterion_vge- input
vim include/tab - input
vim include/et_cotab
What I expected to see
- show file list in
include/ - 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?
41 Answer
Maybe you turned off the completion specifications associated with vim.
complete -p vimAnd check the output:
complete -F _filedir_xspec vimIf is something like the previous line, run the command:
complete -r vimIn 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
#fiAs 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.bashNow edit your .bash_profile using nano .bash_profile or vimadding this:
source /home/tu_usuario_del_host/.wp-completion.bash 7