2

I can not get the autocomplete to work for php files. I added the following to my .vimrc file but when I type ctl + o nothing happnens. When I type ctl + x i get -- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y) at the bottom of vim.

filetype plugin on
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
raym0nd
  • 3,172
  • 7
  • 36
  • 73
Stewy
  • 75
  • 2
  • 7

2 Answers2

8

What you probably want is Ctrl + xCtrl + o in succession.

Incidentally, I map this to Ctrl + Space so as not to feel like I'm using Emacs.

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
  • 2
    also Ctrl + p and Ctrl + n are useful shortcutes to autocomlete words – vsushkov Aug 08 '11 at 17:30
  • @vsushkov Ctl+n will complete from words in current buffers, but not PHP functions and keywords. – Michael Berkowski Aug 08 '11 at 17:32
  • yes, but ctrl +n also really useful. F.e. to complete variable names – vsushkov Aug 08 '11 at 17:36
  • both are very helpful. Thank you both. After I run the ctrl+x ctrl+o It places the function syntax at the top of vim. That is really helpful but how do I remove that once I have finished with that function? It looks like this mysql_connect([string server [, string username [, string password [, bool new_link [, int client_flags]]]]] | resource ~ [Scratch] [Preview] I am almost ready to replace my current IDE with VIM!!! – Stewy Aug 08 '11 at 17:48
  • @Stewy see http://stackoverflow.com/questions/6113316/how-can-i-automatically-close-preview-window-after-i-move-cursor-to-another-windo – Michael Berkowski Aug 08 '11 at 17:53
  • @Stewy or, what I use: `autocmd InsertLeave * if pumvisible() == 0|pclose|endif` Whenever I leave insert mode, the preview window disappears – Michael Berkowski Aug 08 '11 at 17:54
  • Thanks. Just found that as you posted... I didnt know that was called preview. Thanks for your help. I am just learning the powers of VIM – Stewy Aug 08 '11 at 17:56
  • Michael Berkowski, what may i put in ~/.vimrc to accomplish the mapping you describe in the answer? – jrz Oct 26 '12 at 06:40
  • @Jonz I no longer have this mapping, but [here is a comprehensive answer](http://stackoverflow.com/questions/510503/ctrlspace-for-omni-and-keyword-completion-in-vim) – Michael Berkowski Oct 26 '12 at 11:01
0

I think you want ^P, but I'm not sure.

Chris Warrick
  • 1,571
  • 1
  • 16
  • 27