Smart (`infercase`) Dictionary Completions in Vim While Preserving Your Preferred `ignorecase` Settings

Dictionary completions in Vim can use a ‘infer case’ mode, where, e.g.,
“Probab” will correctly autocomplete to, e.g., “Probability”, even though the
entry in the dictionary might be in a different case. The problem is that this
mode only works if `ignorecase` is on. And sometimes, we want one (`infercase`)
but not the other (`ignorecase`).

The following function, if added to your “`~/.vimrc`”, sets it up so that `ignorecase` is
forced on when dictionary completions are invoked via the `` keys,
and then restored to its original state when exiting.

[gist id=10015995]

A better approach than binding all the exit keys would be an autocommand on leaving the pop-up completion menu, but I could only find a trigger for entering the popupmenu.

Leave a Reply

Your email address will not be published. Required fields are marked *