Skip to main content
deleted 3 characters in body
Source Link
Jesus Iniesta
  • 12.9k
  • 3
  • 43
  • 36

Note: these shortcuts only work as expected if you edit your keybindings.json

I wasn't happy with the default shortcuts, I wanted them to work as follow:

  • Fold: Ctrl + Alt + []
  • Fold recursively: Ctrl + ⇧ Shift + Alt + []
  • Fold all: Ctrl + k then Ctrl + []
  • Unfold: Ctrl + Alt + ][
  • Unfold recursively: Ctrl + ⇧ Shift + Alt + ][
  • Unfold all: Ctrl + k then Ctrl + ][

To set it up:

  • Open Preferences: Open Keyboard Shortcuts (JSON) (Ctrl + ⇧ Shift + p)
  • Add the following snippet to that file

Already have custom keybindings for fold/unfold? Then you'd need to replace them.

 { "key": "ctrl+alt+[""ctrl+alt+]", "command": "editor.fold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+alt+]""ctrl+alt+[", "command": "editor.unfold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+[""ctrl+shift+alt+]", "command": "editor.foldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+]""ctrl+shift+alt+[", "command": "editor.unfoldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+[", "command": "-editor"editor.foldAll"unfoldAll", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+]", "command": "editor.unfoldAll"foldAll", "when": "editorTextFocus && foldingEnabled" },   

Note: these shortcuts only work as expected if you edit your keybindings.json

I wasn't happy with the default shortcuts, I wanted them to work as follow:

  • Fold: Ctrl + Alt + [
  • Fold recursively: Ctrl + ⇧ Shift + Alt + [
  • Fold all: Ctrl + k then Ctrl + [
  • Unfold: Ctrl + Alt + ]
  • Unfold recursively: Ctrl + ⇧ Shift + Alt + ]
  • Unfold all: Ctrl + k then Ctrl + ]

To set it up:

  • Open Preferences: Open Keyboard Shortcuts (JSON) (Ctrl + ⇧ Shift + p)
  • Add the following snippet to that file

Already have custom keybindings for fold/unfold? Then you'd need to replace them.

 { "key": "ctrl+alt+[", "command": "editor.fold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+alt+]", "command": "editor.unfold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+[", "command": "editor.foldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+]", "command": "editor.unfoldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+[", "command": "-editor.foldAll", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+]", "command": "editor.unfoldAll", "when": "editorTextFocus && foldingEnabled" },   

Note: these shortcuts only work as expected if you edit your keybindings.json

I wasn't happy with the default shortcuts, I wanted them to work as follow:

  • Fold: Ctrl + Alt + ]
  • Fold recursively: Ctrl + ⇧ Shift + Alt + ]
  • Fold all: Ctrl + k then Ctrl + ]
  • Unfold: Ctrl + Alt + [
  • Unfold recursively: Ctrl + ⇧ Shift + Alt + [
  • Unfold all: Ctrl + k then Ctrl + [

To set it up:

  • Open Preferences: Open Keyboard Shortcuts (JSON) (Ctrl + ⇧ Shift + p)
  • Add the following snippet to that file

Already have custom keybindings for fold/unfold? Then you'd need to replace them.

 { "key": "ctrl+alt+]", "command": "editor.fold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+alt+[", "command": "editor.unfold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+]", "command": "editor.foldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+[", "command": "editor.unfoldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+[", "command": "editor.unfoldAll", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+]", "command": "editor.foldAll", "when": "editorTextFocus && foldingEnabled" }, 
Source Link
Jesus Iniesta
  • 12.9k
  • 3
  • 43
  • 36

Note: these shortcuts only work as expected if you edit your keybindings.json

I wasn't happy with the default shortcuts, I wanted them to work as follow:

  • Fold: Ctrl + Alt + [
  • Fold recursively: Ctrl + ⇧ Shift + Alt + [
  • Fold all: Ctrl + k then Ctrl + [
  • Unfold: Ctrl + Alt + ]
  • Unfold recursively: Ctrl + ⇧ Shift + Alt + ]
  • Unfold all: Ctrl + k then Ctrl + ]

To set it up:

  • Open Preferences: Open Keyboard Shortcuts (JSON) (Ctrl + ⇧ Shift + p)
  • Add the following snippet to that file

Already have custom keybindings for fold/unfold? Then you'd need to replace them.

 { "key": "ctrl+alt+[", "command": "editor.fold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+alt+]", "command": "editor.unfold", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+[", "command": "editor.foldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+shift+alt+]", "command": "editor.unfoldRecursively", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+[", "command": "-editor.foldAll", "when": "editorTextFocus && foldingEnabled" }, { "key": "ctrl+k ctrl+]", "command": "editor.unfoldAll", "when": "editorTextFocus && foldingEnabled" },