Search code examples
vimctagsexuberant-ctags

How to autocomplete in vim based off partial matching via ctags


Example:

In a file in another directory I have a function defined by the following:

def _generator_function_1(self):
   passs

In the file of my current directory, I have typed the following:

def test_generI

where I denotes my cursor position.

I would like to use vim's autocompletion functionality (i.e. via ^n or ^p) to autocomplete the function definition to test_generator_function_1. Is there a way of configuring vim autocompletion to match not based off full-prefixes? Or, is there a way in ctags to generate tags based off keywords instead of full function definitions?

EDIT: To clarify, I am specifically wondering if keyword-based autocompletion exists. I have autocompletion by tags setting up, so if I typed "_gen", then ^n would complete to give me "_generator_function_1". In my example, however, it is because the string is prefixed by "test" that "test_gener" as the starting typed word does not lead to any autocomplete suggestions. So I am wondering if this can somehow be made possible.


Solution

    1. Vim doesn't have "autocompletion functionality". It only has "completion", not "autocompletion". You need a plugin for "autocompletion".
    2. No, there's no way to obtain your desired behavior without some serious vimscripting. See :help complete-functions.