SOunit / vscode-memo

0 stars 0 forks source link

shortcut #1

Open SOunit opened 1 month ago

SOunit commented 1 month ago
SOunit commented 1 month ago

In Visual Studio Code (VSCode), you can easily collapse (or fold) JavaScript code to make your workspace cleaner and more organized. Here's how you can do it:

Manual Collapsing (Folding):

  1. Using the UI:

    • On the left side of your code (near the line numbers), you’ll see a small arrow or chevron next to code blocks (functions, classes, objects, etc.).
    • Click on the arrow to collapse or expand the code block.
  2. Using Shortcuts:

    • Fold (Collapse) Code: Place your cursor within the code block you want to collapse and use:
      • Windows/Linux: Ctrl + Shift + [
      • Mac: Cmd + Shift + [
    • Unfold (Expand) Code: Place your cursor within the collapsed code block and use:
      • Windows/Linux: Ctrl + Shift + ]
      • Mac: Cmd + Shift + ]
  3. Fold/Unfold All Code:

    • Fold All (Collapse All):
      • Windows/Linux: Ctrl + K, then Ctrl + 0
      • Mac: Cmd + K, then Cmd + 0
    • Unfold All (Expand All):
      • Windows/Linux: Ctrl + K, then Ctrl + J
      • Mac: Cmd + K, then Cmd + J

Automatic Collapsing:

// #region Description of this section
function example() {
    // Some code here
}
// #endregion

This will create a collapsible region in your code. You can then fold and unfold this region in the same way as other blocks.

Conclusion: