A strange problem i have, i'm new to VScode, in .js files, code folding works, but when i am editing a .php, code folding doesn't seem to work. No conflicts with any installed extensions. Or does VScode simply just doesn't have this feature??

  • I resorted to using /* #region */ and /* #endregion */ in every function to get the code to collapse.
    – xinthose
    Sep 25, 2019 at 17:49

1 Answer 1


I believe code folding used to be indentation based. Things like a differently-indented HEREDOC really screw that up.

vscode added support for language-aware folding, but it needs an extension to implement it. The vscode team suggests filing an issue against one of the popular PHP extensions:

So to get this implemented, please file a feature request against one the PHP extensions: e.g. https://github.com/felixfbecker/vscode-php-intellisense or https://github.com/bmewburn/vscode-intelephense

ref: https://github.com/microsoft/vscode/issues/37494

  • Wow, you would think they would allow language-based folding to be specified in the config, and not require one of the bloated extensions that insist on trying to do everything, even the things you don't want them to do. Code folding is as standard as syntax highlighting, which is done by default in VSCode, and the code folding should be identical to JS code folding, which is included as standard.
    – SEoF
    Aug 27, 2021 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.