word_complete.vim : automatically offers word completion as you type
| script karma
Downloaded by 15888
Comments, bugs, improvements
script versions (upload new version)
|Each time you type an alphabetic character, the script attempts
to complete the current word. The suggested completion is selected
in Select mode, so you can just type another character to keep going.
Other options: <Tab> to accept, <BS> to get rid of the completion,
<Esc> to leave Insert mode without accepting the completion, <C-N>
or <C-P> to cycle through choices, <C-X> to enter <C-X> mode.
The script works by :imap'ping each alphabetic character, and uses
Insert-mode completion (:help i_ctrl-p). It is far from perfect. For example, the :imap's mean that you are constantly switching out of Insert mode, which means that undo only works a few characters at a time. This also messes up any abbreviations you may have defined. Since Select mode uses the same mappings as Visual mode, the special keys mentioned above may conflict with what you are used to in Visual mode. I have received one report that mswin.vim interferes with this script.
Every second character you type is in Select mode, so with versions of vim before 6.2, completions are offered only half the time.
|:source it from your vimrc file or drop it in your plugin directory.
To activate, choose "Word Completion" from the Tools menu, or type
To make it stop, choose "Tools/Stop Completion," or type
If you want to activate word completion for every buffer, add the line
:autocmd BufEnter * call DoWordComplete()
to your vimrc file.
Click on the package to download.
ip used for rating: 18.104.22.168
||Minor change: I replaced
while letter <= "z"
while letter <=# "z"
(case-sensitive comparison, regardless of 'ignorecase' option) so that if someone decides to add a loop for "A" to "Z" using the same model, (s)he does not get odd results.
||Since vim 7.0 supports :smap (mappings that apply only to Select mode) I updated the script to use these. Now the maps defined by the script for when completion is active will not do anything unexpected in Visual mode.
I also updated the installation instructions in the comments at the top of the file.
||I added a configuration section. You can now change
(1) a minimum length of word to be completed
(2) the character (default <Tab>) used to accept the completion.
I also added some comments and separated a StartAppend() function (which is called twice).
||better support for keymaps
||This version tries to treat :lmap's (and keymaps) properly.
Minor improvement: completion is attempted before
punctuation, as well as at the end of a line or before white space.
This version will probably no longer work with vim 5.x.