3

PHP has some pretty inconsistent parameters for functions (e.g. sometimes first haystack, then needle, and sometimes the other way around). I'd like vim to somehow hint at what parameters are expected. I mostly care for integrated PHP functions, not for project-specific functions. Is this possible to set up / configure?

My idea is that I type:

strpos(

and vim tells notifies me it expects $haystack, $needle.

3 Answers3

6

What version of Vim do you use?

Without any additional plugin or configuration, hitting <C-x><C-o> after typing a couple of letters of a builtin function you are supposed to get the omnicompletion menu and a small preview window showing the signature of the currently selected function. See :help compl-omni and :help ft-php-omni

With strpos(, you should get:

strpos(string haystack, mixed needle [, int offset] | int

You might want to try this slightly better omnicompletion script for PHP.

romainl
  • 186,200
  • 21
  • 280
  • 313
2

The excellent vim plugin PIV does something quite similar. If you press shift-K on a function, you get an in-vim offline view of the function's manual page -- Which doesn't only show what parameters the function expects, but also how to use them.

That's only one of PIV's useful features. It can for example also auto-fill a parameter with a known variable when you press <tab> in in the function's brackets. (I do believe this requires SuperTab to be installed though)

Rem.co
  • 3,813
  • 3
  • 29
  • 37
0

Tag List might help you. See this related answer

Community
  • 1
  • 1
CamelBlues
  • 3,444
  • 5
  • 29
  • 37