Vim has some powerful autocompletion features. Out of the box autocompletion for insert mode is a sub mode which you access using Ctrl X. If you view the help file:
You can find out all you need to know about the default Vim autocomplete functionality.
Autocompletion can draw it’s matches from many different sources. Below is a list ( taken from the help file ), which I am going to explore a bit.
Whole lines i_CTRL-X_CTRL-L
keywords in the current file i_CTRL-X_CTRL-N
keywords in ‘dictionary’ i_CTRL-X_CTRL-K
keywords in ‘thesaurus’, thesaurus-style i_CTRL-X_CTRL-T
keywords in the current and included files i_CTRL-X_CTRL-I
file names i_CTRL-X_CTRL-F
definitions or macros i_CTRL-X_CTRL-D
Vim command-line i_CTRL-X_CTRL-V
User defined completion i_CTRL-X_CTRL-U
omni completion i_CTRL-X_CTRL-O
Spelling suggestions i_CTRL-X_s
keywords in ‘complete’ i_CTRL-N
On Mac OSX Lion, the dictionary files are located at
so, in your vimrc …
Now you have autocompletion with 235886 words at your disposal! You can actually give ‘dictionary’ a list, for example you could also add the propernames file at /usr/share/dict/propernames.
Unfortunately, the thesaurus on a Mac is stored in a binary format, so is inaccessible to Vim. Instead, check out https://github.com/sgur/thesaurus-gutenberg.vim, it’s a pre-defined thesaurus for Vim.
** Update: not sure if this plugin works **
This option lets you include words from other files in the include path, if you use ctags, this is almost not necessary in my mind.
Vim’s autocomplete can use the tags file generated by ctags to give you a match, this is very useful if you want to use class, method or varibale names accross classes.
Definitions and macros
Not really sure how this works
Completing Vim commands
This is really just for when you are writing vimscript and want to autocomplete some Vim command, it doesn’t work in Visual Mode or Command line mode.
User defined completion
This function looks like it could be really powerful as it lets you define your own custom function for autocompletion. Perhaps the topic of another post :)
My personal favorite, as recommended by a colleague: https://github.com/ervandew/supertab