Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim folding for PHP [duplicate]

Tags:

php

vim

folding

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?

like image 537
John Doe Avatar asked Nov 28 '09 16:11

John Doe


1 Answers

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.

like image 59
mmrobins Avatar answered Sep 28 '22 09:09

mmrobins