Vim provides nice syntax folding for Ruby and C (well, that is what I've tried) out of the box, but what about PHP? It doesnt have this feature! Am I missing something?
Asked
Active
Viewed 6,246 times
6
-
What makes you think folding doesn't work out of the box for PHP? I don't use folding or PHP a lot (mostly Perl and Ruby), but it seems to work to me for PHP files. What are you trying to fold? Functions and conditionals (because those seem to work) or something else? – mmrobins Nov 28 '09 at 16:55
2 Answers
8
Folding should work in just about any language that uses parens or brackets, so it should work in PHP. I've added the following few lines as key shortcuts in my .vimrc so that I can automatically fold and unfold all my function definitions in a file quickly by typing comma f or F:
" Folding and unfolding
map ,f :set foldmethod=indent<cr>zM<cr>
map ,F :set foldmethod=manual<cr>zR<cr>
From there you can unfold, or refold levels using z and whatever fold command you like. Good tutorial here.

mmrobins
- 12,809
- 7
- 41
- 42
-
-
An old xmarks entry says the title was "Linux.com :: Vim tips: Folding fun", which would suggest this as an updated link, and the Internet Archive confirms it: http://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun – cincodenada Dec 08 '11 at 00:39
3
there is a plugin that should solve your problem

Eineki
- 14,773
- 6
- 50
- 59
-
It doesn't fold newly written lines for me so I have to reenable it mannualy every time I have finished writing portion of code. – John Doe Nov 28 '09 at 17:05