diff --git a/src/Actions/Fold.ts b/src/Actions/Fold.ts new file mode 100644 index 00000000..de3074e0 --- /dev/null +++ b/src/Actions/Fold.ts @@ -0,0 +1,20 @@ +import {commands} from 'vscode'; + +export class ActionFold { + + static fold(): Thenable { + return commands.executeCommand("editor.fold"); + } + + static unfold(): Thenable { + return commands.executeCommand("editor.unfold"); + } + + static foldAll(): Thenable { + return commands.executeCommand("editor.foldAll"); + } + + static unfoldAll(): Thenable { + return commands.executeCommand("editor.unfoldAll"); + } +} diff --git a/src/Modes/Normal.ts b/src/Modes/Normal.ts index 7f5cdb34..85112a57 100644 --- a/src/Modes/Normal.ts +++ b/src/Modes/Normal.ts @@ -21,6 +21,7 @@ import {ActionHistory} from '../Actions/History'; import {ActionIndent} from '../Actions/Indent'; import {ActionFilter} from '../Actions/Filter'; import {ActionMode} from '../Actions/Mode'; +import {ActionFold} from '../Actions/Fold'; import {MotionCharacter} from '../Motions/Character'; import {MotionLine} from '../Motions/Line'; @@ -182,6 +183,10 @@ export class ModeNormal extends Mode { { keys: 'z .', actions: [ActionReveal.primaryCursor], args: {revealType: TextEditorRevealType.InCenter} }, { keys: 'z z', actions: [ActionReveal.primaryCursor], args: {revealType: TextEditorRevealType.InCenter} }, + { keys: 'z c', actions: [ActionFold.fold]}, + { keys: 'z o', actions: [ActionFold.unfold]}, + { keys: 'z M', actions: [ActionFold.foldAll]}, + { keys: 'z R', actions: [ActionFold.unfoldAll]}, { keys: '.', actions: [this.repeatRecordedCommandMaps.bind(this)] }, diff --git a/src/Modes/Visual.ts b/src/Modes/Visual.ts index 9952640b..a599ddac 100644 --- a/src/Modes/Visual.ts +++ b/src/Modes/Visual.ts @@ -15,6 +15,7 @@ import {ActionJoinLines} from '../Actions/JoinLines'; import {ActionFilter} from '../Actions/Filter'; import {ActionFind} from '../Actions/Find'; import {ActionMode} from '../Actions/Mode'; +import {ActionFold} from '../Actions/Fold'; import {MotionLine} from '../Motions/Line'; export class ModeVisual extends Mode { @@ -84,6 +85,11 @@ export class ModeVisual extends Mode { { keys: 'V', actions: [ActionMode.toVisualLine] }, { keys: 'v', actions: [ActionSelection.shrinkToActives] }, + { keys: 'z c', actions: [ActionFold.fold]}, + { keys: 'z o', actions: [ActionFold.unfold]}, + { keys: 'z M', actions: [ActionFold.foldAll]}, + { keys: 'z R', actions: [ActionFold.unfoldAll]}, + { keys: 'ctrl+c', actions: [ActionSelection.shrinkToActives] }, { keys: 'ctrl+[', actions: [ActionSelection.shrinkToActives] }, { keys: 'escape', actions: [ActionSelection.shrinkToActives] }, diff --git a/src/Modes/VisualLine.ts b/src/Modes/VisualLine.ts index 4f1145f7..882f0f1d 100644 --- a/src/Modes/VisualLine.ts +++ b/src/Modes/VisualLine.ts @@ -15,6 +15,7 @@ import {ActionFilter} from '../Actions/Filter'; import {ActionFind} from '../Actions/Find'; import {ActionMode} from '../Actions/Mode'; import {ActionIndent} from '../Actions/Indent'; +import {ActionFold} from '../Actions/Fold'; import {MotionLine} from '../Motions/Line'; export class ModeVisualLine extends Mode { @@ -85,6 +86,11 @@ export class ModeVisualLine extends Mode { { keys: 'v', actions: [ActionMode.toVisual] }, { keys: 'V', actions: [ActionSelection.shrinkToActives] }, + { keys: 'z c', actions: [ActionFold.fold]}, + { keys: 'z o', actions: [ActionFold.unfold]}, + { keys: 'z M', actions: [ActionFold.foldAll]}, + { keys: 'z R', actions: [ActionFold.unfoldAll]}, + { keys: 'ctrl+c', actions: [ActionSelection.shrinkToActives] }, { keys: 'ctrl+[', actions: [ActionSelection.shrinkToActives] }, { keys: 'escape', actions: [ActionSelection.shrinkToActives] },