Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM for PHP: List if()'s and include()'s in Taglist

Tags:

php

vim

taglist

I use Taglist in VIM, but one particular PHP application which I have inherited is coded with if()'s and elseif()'s and include()'s extensively. Not a single method or function in almost 5000 lines of code per file (and tens or hundreds of files). Is there any way to use Taglist or another plugin to get an overview of the code flow? I'm thinking of something along the lines of showing the conditions in the if()'s in a concise manner in the sidebar, including their hierarchy. Anything remotely close to that would be great.

Thanks!

like image 758
dotancohen Avatar asked Oct 23 '11 21:10

dotancohen


2 Answers

this involves a little bit work, you'll need to compile a modified version of exuberant ctags with modified rules for php.

you might want to have a look over here: http://ctags.sourceforge.net/EXTENDING.html

like image 119
Lucy Avatar answered Nov 02 '22 02:11

Lucy


Using foldlist plugin along with foldmethod-syntax (or tweaking your own foldmethod-expr) would work nicely.

In fact, even without the plugin I believe a proper fold setting would work miracles. Some recommendations:

  • set foldmethod=syntax or (set foldmethod=expr and set foldexpr=... for your case)
  • set foldclose=all to hide all those nasty ifs
  • set foldcolumn=2 or greater to see the nesting level
  • set foldtext=MyFoldText() and make a function to show you relevant information,

like:

function! MyFoldText()
   let line = getline(v:foldstart)
   let line = substitute(line, 'if(\(.*\)).*', 'if: \1', 'g')
   " ... etc
   return line
endfunction
like image 36
Eelvex Avatar answered Nov 02 '22 01:11

Eelvex