VIM for PHP: List if()'s and include()'s in 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!


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


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
    
    链接地址: http://www.djcxy.com/p/55758.html

    上一篇: 抽象DateTime.Current依赖

    下一篇: VIM for PHP:在Taglist中列出if()和include()