Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

collapse or folding "import" statements in vscode (for java code)

Is it possible to enable some option to fold or collapse groups of import statements in java code using vscode?

Are there any extensions that do this job?

like image 983
danilo Avatar asked Feb 12 '19 18:02

danilo


People also ask

How do you collapse the code in VS code?

Fold Recursively (Ctrl+K Ctrl+[) folds the innermost uncollapsed region at the cursor and all regions inside that region. Unfold Recursively (Ctrl+K Ctrl+]) unfolds the region at the cursor and all regions inside that region. Fold All (Ctrl+K Ctrl+0) folds all regions in the editor.

How do you collapse and expand code in Visual Studio code?

Ctrl + Shift + [ on Windows and Linux. ⌥ + ⌘ + [ on macOS.

How do you collapse all Methods in Visual Studio code?

Ctrl+K Ctrl+[ Fold (collapse) all subregions editor. Ctrl+K Ctrl+] Unfold (uncollapse) all subregions editor.


1 Answers

As an alternative, consider VSCode 1.59 (Juil. 2021), which includes:

Automatically Fold Imports

Use the setting editor.foldingImportsByDefault to have import statements automatically folded.

The fold state is stored once a file has been opened once.

The feature works with TypeScript, JavaScript, Java, C# and C++ and with all language that have a folding range provider that annotates import statements with FoldingRangeKind.Imports.

like image 188
VonC Avatar answered Oct 06 '22 14:10

VonC