If you are a VS Code user then should know about the section collapsing and uncollapsing. Coding is not an easy job when you don't understand the code. To make coding fluent and understandable we have to focus on different tricks. Here in this article, I will show you that how to collapse a section of code in Visual Studio Code.
Manual method
You can apply multiple methods to do that. To collapse or fold a section of code you can follow the steps given below.
Step 1: Find drop-down signs beside line numbers
In VS Code you can track your code line number. You have to take your mouse pointer near line numbers. Besides line numbers, you can find a drop-down sign which looks like a 'V' sign. That is actually the sign of unfolded section of code. Here is the screenshot of that:
Step 2: Click on the drop-down sign
For the first click on the icon, the section of code will fold and the next click will unfold the section. Section of code can be a div, function, statement, elements, etc. Here in the picture, you can see that the function area folded after clicking on that icon.
Keyboard shortcut method
Keyboard shortcuts help us to do things fast. Here I am sharing the keyboard shortcut for windows, Linux, and Mac. Just place the cursor on the section of code then apply the keyboard shortcut.
Windows and Linux
Work | Keyboard Shortcut |
---|---|
Fold The Sections of Code | Ctrl + Shift + [ |
Unfold The Sections of Code | Ctrl + Shift + ] |
Mac
Work | Keyboard Shortcut |
Fold The Sections of Code | ⌥ + ⌘ + [ |
Unfold The Sections of Code | ⌥ + ⌘ + ] |
In this way, you can easily collapse sections of code using the keyboard shortcut. This will make your code simple and easy to understand. If the code is easy to understand then it is also easy to debug. Follow our blog for more articles about vs code. We have many informative articles about programming and different IDE.