Search code examples
phpvimidectags

VIM: Show PHP function / class in command line?


Is there any way to show the current PHP function or class name in the VIM command line? I found a plugin for showing C function names in the status line but it does not work for PHP and in any case I prefer the command line be used to save valuable vertical lines.

Thanks.


Solution

  • EDIT

    While looking for something completely unrelated in TagList's help I've just found these two functions:

    Tlist_Get_Tagname_By_Line()
    Tlist_Get_Tag_Prototype_By_Line()
    

    Adding this in my statusbar works beautifully:

    %{Tlist_Get_Tagname_By_Line()}
    

    Also, did you read the Vim Wiki? It has a bunch of tips trying to adress the same need. There is also this (untested) plugin.

    ENDEDIT

    If you are short on vertical space maybe you won't mind using a bit of horizontal space?

    TagList and TagBar both show a vertical list of the tags used in the current buffer (and other opened documents in TagList's case) that you can use to navigate your code.

    However, I'm not particularly a fan of having all sorts of informations (list of files, VCS status, list of tags, list of buffers/tabs…) displayed at all times: being able to read the name of the function you are in is only useful when you actually need to know it, otherwise it's clutter. Vim's own [{ followed by <C-o> are enough for me.