sponsor Vim development Vim logo Vim Book Ad

context_complete.vim : Context sensitive word completion

 script karma  Rating 30/15, Downloaded by 1950  Comments, bugs, improvements  Vim wiki

created by
David Larson
 
script type
utility
 
description
The focus of this script is to provide context-sensitive word completion - taking advantage of the popular ctags utility and Vim's built-in perl features.

Suppose you have an instance of an object (o), and you've typed:

o.set_

While you are still in insert mode, press CTRL-J, and this script will then look up the first member of that object that starts with "set_" and complete it for you, like this:

o.set_range(integer max, integer min)

If this isn't the completion that you want, then press CTRL-J again for the next member that starts with "set_":

o.set_name(string name)

and again for the next one:

o.set_value

If you've gone too far then you can go back with CTRL-K. After each completion you are left in insert mode - so you can just continue typing when you've found the one you want.

The object can also be replaced with a struct, class, 'this', or 'super'.

Completions can also be made after the open parentheses to complete the list of parameters:

o.set_range(<c-j>

Or after the function:

o.get_name().compar<c-j>

Pressing CTRL-S will skip through the function parameters, visually selecting each in turn - useful for filling in the parameters after completing a function.
 
install details
Unpack the tar file into ~/.vim. Then from any vim window type :helptags ~/.vim/doc. You can read the installation details at :help context_complete-setup
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
context_complete1.0.tar 1.0 2005-03-04 6.0 David Larson Major upgrade.
- context completion continues after a function (var.getObject().<c-j>)
- search pattern and keywords are configurable
- added a new mapping to highlight parameter items in turn
- added a tag cache file for mega-fast searching.
- *much* more.
context_complete.tar 0.5 2005-02-10 6.0 David Larson - completes 'this.<c-q>'
- completes 'super.<c-q>'
- object type guessing is smarter - limits tag choises to members of the current object.
- more bug fixes and documentation.
context_complete.tar 0.4 2005-01-31 6.0 David Larson - implemented a basic understanding of class inheritance.
- tag searching is now *much* faster - uses binary searching whenever possible.
- function parameter completions are given when asked after "(". e.g.: util.do_suff(<c-q>
- completion suggestions are now sorted.
context_complete.vim 0.3 2005-01-24 6.0 David Larson - static members are completed: i.e. ClassName::<c-q>
- C structs are now understood and treated like classes
- local variable definition detection is much better... it uses more of vim's built-in features. (yay!)
- more bug fixes. Finding the definition of a local variable is much more solid.
ip used for rating: 13.58.121.131

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github