Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97327

Switch case auto indentation to enable folding on VSCode

$
0
0

I am using Visual Studio Code, and in one of my projects I have a huge switch-case statement that I want to be able to read through easily by collapsing individual case '...': statements.

By doing research, I've found that I had to change Folding Strategy from auto to indentation in the settings to be able to fold cases individually. This works wonder like in this example :

switch (cmdPrimary) {
   case 'help':
      // code
   break;
   case 'ping':
      // code
   break;
}

This is how it looks like in the editor with folding

However, now, whenever I use the auto-indentation, VSCode changes my code to look like this :

switch (cmdPrimary) {
   case 'help':
   //code
   break;
   case 'ping':
   //code
   break;
}

This is how it looks like in the editor

As you can see, I can no longer fold my individual cases because auto-indentation actually removed the indentation that each cases' code had.

I don't really care about the indentation of my code as long as I can fold cases individually.

Is there any way I could either make auto-indentation work differently for switch-cases, or just let VSCode fold individual cases without using Folding Strategy to indentation ?

Thanks a lot for any answer.


Viewing all articles
Browse latest Browse all 97327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>