Vim 7 Autocomplete

Vim 7.0 was lauched sometime back, but I wasn’t able to check it, But its awesome. The Autocomplete or intellisense built is just too good. It supports various filetypes, it will complete the function as well as show a preview of what arguments are expected out of it.

First check if you have Vim 7 installed and in the VIM directory if you have a folder called autoload. If you have check if it contains *complete.vim files. If everything is Good… lets move…

Lets add PHP autocomplete feature. In your $HOME/.vimrc file add the following command

autocmd FileType php set omnifunc=phpcomplete#CompletePHP

Once done, Open any PHP file and within the <?php tag, write mysql_c and press Ctrl-x Ctrl-o , and here is what happens

Vim 7 PHP autocomplete

You can see a Full list of functions begining with mysql_c

The .vimrc command that we added supports intellisense like autocomplete only for PHP filetypes, note FileType php in the statement. If you want to add support for the other languages as well

  • Open the autoload/<filetype>complete.vim file
  • Check for intial lines like …
    function! htmlcomplete#CompleteTags(findstart, base)
    if a:findstart
  • Now, I had opened htmlcomplete.vim file, Now to add support for html files…
    • Add the following command
      autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

Thats it ! add more support the way you want…


8 Responses to “Vim 7 Autocomplete”

  1. ruturajv Says:

    If you want to load all the plugins depending upon the file types. Add the following command in your ~/.vimrc file

    setlocal omnifunc=syntaxcomplete#Complete

  2. Raging_Hog Says:

    Is there a way to see the function’s parameter when there’s only one match?

    I write this

    or maybe even just this

    then press (C-X)(C-O) and I’d get the preview of the function prototype.

  3. Raging_Hog Says:


    set cot+=menuone

  4. ruturajv Says:

    thanks for that

  5. freelabs @ » links for 2007-03-27 Says:

    […] Vim 7 Autocomplete « GET / HTTP/1.1 (tags: editor php programming tools vim autocomplete blog) Socializza questo post: These icons link to social bookmarking sites where readers can share and discover new web pages. […]

  6. Stargazers Says:

    Thank you very much about this easy tutorial 🙂 It helped me lot!

  7. kapil Says:

    I have just started using vim as an editor…but
    soon realized that its not just editor…its an IDE…
    its really helpful when u r lost in IDEs….
    Nice post…
    thanx a lot and expecting more on vim here. 🙂

  8. henkie Says:

    Looks liek vim is turnan into emacs =)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: