In Vim versuche ich, alle Klassenmethoden automatisch klappen zu lassen, wenn ich eine Datei öffne

1346
Matt Alexander

Wenn ich eine PHP-Datei öffne, die eine Klasse enthält, wie kann ich dann das Dokument automatisch so falten?

In Vim versuche ich, alle Klassenmethoden automatisch klappen zu lassen, wenn ich eine Datei öffne

0

2 Antworten auf die Frage

3
romainl

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.

2
Heptite

Vielleicht möchten Sie Ihre 'foldmethod'-Option auf "Syntax" setzen?

:set fdm=syntax 

Wenn dies wie gewünscht funktioniert, können Sie diesen Befehl ~/.vim/ftplugin/php.vim( ~/vimfiles/ftplugin/php.vimunter Windows) eingeben, damit er beim Öffnen eines PHP-Puffers automatisch ausgeführt wird.

Bearbeiten: Ich habe festgestellt, dass Sie möchten, dass die Klassendeklaration standardmäßig nicht gefaltet wird. Versuchen Sie dazu:

:set foldlevel=1