diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index 32aadbe4451..dd9c17d51d8 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -14,6 +14,7 @@ import { allowVSCodeToPropagateCursorUpdatesAndReturnThem } from '../../util'; import { isTextTransformation } from './../../transformations/transformations'; import { FileCommand } from './../../cmd_line/commands/file'; import { QuitCommand } from './../../cmd_line/commands/quit'; +import { OnlyCommand } from './../../cmd_line/commands/only'; import * as vscode from 'vscode'; import * as util from './../../util'; import { RegisterAction } from './../base'; @@ -2157,6 +2158,18 @@ class CommandQuit extends BaseCommand { } } +@RegisterAction +class CommandOnly extends BaseCommand { + modes = [ModeName.Normal]; + keys = [["", "o"], ["", "C-o"]]; + + public async exec(position: Position, vimState: VimState): Promise { + new OnlyCommand({}).execute(); + + return vimState; + } +} + @RegisterAction class MoveToRightPane extends BaseCommand { modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine]; diff --git a/src/cmd_line/commands/only.ts b/src/cmd_line/commands/only.ts new file mode 100644 index 00000000000..0eaf418f6fa --- /dev/null +++ b/src/cmd_line/commands/only.ts @@ -0,0 +1,24 @@ +"use strict"; + +import * as vscode from "vscode"; +import * as node from "../node"; + +export class OnlyCommand extends node.CommandBase { + protected _arguments: {}; + + constructor(args: {}) { + super(); + + this._name = 'only'; + this._arguments = args; + } + + get arguments(): {} { + return this._arguments; + } + + async execute(): Promise { + await vscode.commands.executeCommand("workbench.action.closeEditorsInOtherGroups"); + return; + } +} \ No newline at end of file diff --git a/src/cmd_line/subparser.ts b/src/cmd_line/subparser.ts index 78e9c050f19..9d3a7ea86e7 100644 --- a/src/cmd_line/subparser.ts +++ b/src/cmd_line/subparser.ts @@ -15,6 +15,7 @@ import { parseRegisterCommandArgs } from './subparsers/register'; import { parseDeleteRangeLinesCommandArgs } from './subparsers/deleteRange'; import { parseSortCommandArgs } from './subparsers/sort'; import { parseCloseCommandArgs } from './subparsers/close'; +import { parseOnlyCommandArgs } from './subparsers/only'; // maps command names to parsers for said commands. export const commandParsers = { @@ -85,6 +86,7 @@ export const commandParsers = { vne: fileCmd.parseEditNewFileInNewWindowCommandArgs, new: fileCmd.parseEditNewFileInNewWindowCommandArgs, vnew: fileCmd.parseEditNewFileInNewWindowCommandArgs, + only: parseOnlyCommandArgs, set: parseOptionsCommandArgs, se: parseOptionsCommandArgs, diff --git a/src/cmd_line/subparsers/only.ts b/src/cmd_line/subparsers/only.ts new file mode 100644 index 00000000000..ddbe9e8663a --- /dev/null +++ b/src/cmd_line/subparsers/only.ts @@ -0,0 +1,7 @@ +"use strict"; + +import * as node from "../commands/only"; + +export function parseOnlyCommandArgs(args: string): node.OnlyCommand { + return new node.OnlyCommand({}); +} \ No newline at end of file