0
When I open a PHP file that contains a class, how can I have Vim automatically fold the document up like this?:
0
When I open a PHP file that contains a class, how can I have Vim automatically fold the document up like this?:
2
Perhaps you want to set your 'foldmethod' option to "syntax"?
:set fdm=syntax
If this works as desired, you can put that command in ~/.vim/ftplugin/php.vim
(~/vimfiles/ftplugin/php.vim
on Windows) to make it automatic when you open a PHP buffer.
Edit: I realized that you may want the class declaration not to be folded by default. To do so, try:
:set foldlevel=1
3
I think that this combination should work:
set foldmethod=indent
set foldlevelstart=4
You might need to adjust the value of foldlevelstart
.
If you only want the functions themselves to be collapsed (and not any blocks within them), you may also want to adjust the value of foldnestmax
to be equal to what you set in foldlevelstart
.
If you are doing that to have a bird's view of your code you might be intereted by TagList or TagBar.