If you need to further fine-tune the folding feature in VSCode, you can install Explicit Folding by zokugun. "editor.foldingStrategy": "indentation", Code language: JavaScript ( javascript ) You can try specifying the editor.foldingStrategy key in settings.json to overcome this problem. In rare cases, VSCode cannot accurately detect the language you’re editing, so you won’t be able to fold your code. "editor.showFoldingControls": "always", Code language: JavaScript ( javascript )Ĭollapse/expand feature works by detecting the language in the file, then apply appropriate settings created specifically for it, either indentation-based, or defined by contributed folding range providers. Controls when the folding controls on the gutter are shown. Alternatively, open Command Palette and find Open Settings (JSON) to open settings.json. You can do that by accessing File > Preferences or press Ctrl +, key combination. You can change that to always show the icon by editing VSCode settings.json and changed the editor.showFoldingControls setting to always. Advanced Collapse Settingsīy default, the collapse icon in the sidebar are shown only when the mouse is moved over the sidebar gutter. Any regions inside the block of code you’re interacting with will be collapsed if previously expanded and vice versa. Recursive Collapse or Expand in VSCodeĭevelopers usually want to recursively collapse or expand a block of code can do that in VSCode by holding Shift key and Click in the arrow icon in the left sidebar. On macOS, you have to use use ⌘ key instead of Ctrl on each of the shortcut above. Fold All Block Comments ( Ctrl+K Ctrl+/ ) folds all regions that start with a block comment token.Fold Level X ( Ctrl+K Ctrl+2 for level 2) folds all regions of level X, except the region at the current cursor position.Unfold All ( Ctrl+K Ctrl+J ) unfolds all regions in the editor.F old All ( Ctrl+K Ctrl+0 ) folds all regions in the editor.Unfold Recursively ( Ctrl+K Ctrl+] ) unfolds the region at the cursor and all regions inside that region.Fold Recursively ( Ctrl+K Ctrl+[ ) folds the innermost expanded region at the cursor and all regions inside that region.Toggle Fold ( Ctrl+K Ctrl+L ) folds or unfolds the region at the cursor.There are several advanced keyboard shortcut to fold/unfold code blocks in VSCode, although I personally don’t use them very often. You can quickly fold a block of code, given that your cursor is placed inside of it by pressing Ctrl+Shift+ key combination will unfold the collapsed region at the cursor.Īlternatively, one can use the Command Palette and type fold to do the same thing, although it will take more than one keyboard shortcut to complete In VSCode terminology, the collapsible code blocks feature is called Fold/Unfold. In this short article, we will present a few handy shortcuts to quickly collapse/expand code blocks in VSCode. You can quickly collapse any block of code using the little arrow in the left sidebar, right beside line numbers. VSCode has automatic code blocks formatting built-in. If you’re a developers, there may be times that you need to deal with complex JSON or HTML files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |