vim has a great feature that allows to auto-complete a word while typing it in insert mode. This article shows how it works.
If you know that the word appeared earlier in the same text file, you can type the first letters then press CTRL-x CTRL-p. If the word you are typing appears later in the text then press CTRL-x CTRL-n. This will create a menu that shows the different possible matching words that have the same prefix.
When writing a program and you want to insert a function call, and you just remember how the function starts.
You can type the beginning of the function name then press CTRL-x CTRL-]. This will create a menu with alternative candidates for the symbol you typed. You need to create a tag file using ctags to use the latter feature.
This is the list of available auto-completion commands in vim.
Completion can be done for: 1. Whole lines |i_CTRL-X_CTRL-L| 2. keywords in the current file |i_CTRL-X_CTRL-N| 3. keywords in 'dictionary' |i_CTRL-X_CTRL-K| 4. keywords in 'thesaurus', thesaurus-style |i_CTRL-X_CTRL-T| 5. keywords in the current and included files |i_CTRL-X_CTRL-I| 6. tags |i_CTRL-X_CTRL-]| 7. file names |i_CTRL-X_CTRL-F| 8. definitions or macros |i_CTRL-X_CTRL-D| 9. Vim command-line |i_CTRL-X_CTRL-V| 10. User defined completion |i_CTRL-X_CTRL-U| 11. omni completion |i_CTRL-X_CTRL-O| 12. Spelling suggestions |i_CTRL-X_s| 13. keywords in 'complete' |i_CTRL-N|
See help completion in vim for more info.
| Labels: unix, coding, howto |
|