Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include a directory recursively for vim autocompletion

Tags:

vim

I use vim from the base directory of my source code. I would like to have autocomplete consider every word of every file in this directory (and subdirectories) when editing a single file.

like image 405
Dan Billings Avatar asked Dec 08 '22 21:12

Dan Billings


1 Answers

Completion is controlled by the 'complete' option. With the k flag, you can have Vim scan files. The ** wildcard stands for a recursive descent into subdirectories. Voila:

:set complete=k**/*

When you want to keep the other default locations (other buffers, included files, etc.), use :set complete+= to add to it.


Alternatively, as this can be too slow for a default, you can use the 'dictionary' option and use Ctrl-X Ctrl-K completion:

:set dictionary=**/*
like image 157
Ingo Karkat Avatar answered Feb 11 '23 02:02

Ingo Karkat