Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How VIM Autocomplete Work

I was going over VIM shortcuts & found the CTRL+p which acts as an autocomplete in UNIX (you know what I am saying, a dropdown list of the possible words to use, sorted by frequency of usage). It seems to detect even the most immediately typed words. How does this work in VIM? I am specifically interested in the data structures that are used for this?

Is there some indexing going on, which dynamically keeps adding new words to its index as they are typed? It has saved me tons of time off-late. By the way VIM Rocks :)

like image 963
Srikar Appalaraju Avatar asked Sep 13 '10 10:09

Srikar Appalaraju


1 Answers

The beauty of a project like Vim is that it is open source. Instructions as to how you can download the source are on the Vim Download page.

If you take a look at edit.c, you'll find a struct called compl_S. That will be a good starting point if you want to understand how Vim's completion works.

like image 108
Johnsyweb Avatar answered Oct 05 '22 19:10

Johnsyweb