Search code examples
vimautocompleteclang-complete

Run a shortcut event on key press in vim


I am using clang_complete with vim which supports autocomplete for variables using short cut <Ctrl-x Ctrl-u>. But I want autocomplete to happen with every keypress i.e. whenever I press a character, autocomplete list shown be shown.

I found that CursorMovedI is an autocmd-event in vim but I could not find any help on autocmd-event.

Please help me find out the way to make autocomplete possible on every keypress.


Solution

  • You may be used to that feature from IDEs, but I would recommend against this in Vim. The popup will interfere with editing, if only by slowing down Vim.

    Nonetheless, if you would like to give this a try, there are plugins that can achieve that. AutoComplPop is an old (and I think by now unmaintained) plugin that provides this functionality; by default for built-in completions, but you can also configure user completions.

    There may be other plugins (YCM?, neocomplcache?) that provide similar functionality, so do some research. If you still would like to implement such yourself, you probably find useful information in those, too. (But be warned that such implementation isn't trivial.)