Skip to content

VSCode Import Folding #15218

Closed
Closed

Description

@TylerYep

Currently, there is no way to collapse a large page of Python imports because VSCode's default folding is indentation-based.

However, there should be a way to create a custom folding rule so that Python imports at the top of the page can be collapsed.

Ideally, there would also be a setting to automatically collapse imports whenever a python file is opened.

Thanks!

Activity

  1. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 25, 2021
  2. karthiknadig commented on Jan 25, 2021

    @karthiknadig
    Member

    Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.

  3. nfx commented on Feb 14, 2021

    @nfx

    Karthik Nadig (@karthiknadig) this is standard behavior for IntelliJ and for VSCode-GoLang.

  4. nfx commented on Feb 17, 2021

    @nfx

    Jim Griesmer (@greazer), Joyce Er (@joyceerhl), Rich Chiodo (@rchiodo) I think this is a good issue to put on editor roadmap.

  5. melMass commented on Aug 12, 2021

    @melMass

    Region is quite nice and easy to extend (configuration based)
    So you can do:

    #region imports <- This is foldable
    from functools import lru_cache
    #endregion
  6. HappyCuppy commented on Oct 5, 2021

    @HappyCuppy

    Region is quite nice and easy to extend (configuration based) So you can do:

    #region imports <- This is foldable
    from functools import lru_cache
    #endregion

    I wasn't able to get this to work with Python (works fine for me with JS with the provided config example, though). What's your config for it for Python?

  7. melMass commented on Oct 5, 2021

    @melMass

    Region is quite nice and easy to extend (configuration based) So you can do:

    #region imports <- This is foldable
    from functools import lru_cache
    #endregion

    I wasn't able to get this to work with Python (works fine for me with JS with the provided config example, though). What's your config for it for Python?

    It should be working by default:
    https://github.com/maptz/maptz.vscode.extensions.customfolding/blob/de39a96ae09341d31a299120b074bb821ec9a44e/src/config/DefaultConfiguration.ts#L138

  8. nfx commented on Oct 7, 2021

    @nfx

    Mel Massadian (@melMass) i don't want to install any third party extensions and modify the code in order to achieve pretty standard functionality - import folding, so that's why i'm raising this as a feature request

  9. melMass commented on Oct 7, 2021

    @melMass

    Mel Massadian (@melMass) i don't want to install any third party extensions and modify the code in order to achieve pretty standard functionality - import folding, so that's why i'm raising this as a feature request

    I was answering to HappyCuppy.

  10. luabud commented on Jan 28, 2022

    @luabud
    Member

    Import folding is now working on the latest release of Pylance. The only missing bit is supporting a setting to automatically do it for Python files.

  11. luabud commented on Jan 29, 2022

    @luabud
    Member

    And I just found out we actually respect "editor.foldingImportsByDefault": true. When you flip it for the first time you may need to wait a bit for the Python and Pylance extensions to activate and do its magic, but it works 😊

  12. TylerYep commented on Jan 29, 2022

    @TylerYep
    Author

    Thank you!! This is so awesome :)

  13. locked as resolved and limited conversation to collaborators on Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-editor-*User-facing catch-allfeature-requestRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunities

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions