mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-08-16 15:50:35 +03:00
Add Tab Support
This commit is contained in:
parent
8312673f8e
commit
ca23b6641b
10
ROADMAP.md
10
ROADMAP.md
@ -380,3 +380,13 @@ Status | Command | Description
|
||||
---|--------|------------------------------
|
||||
| :r [file] | insert the contents of [file] below the cursor
|
||||
| :r! {command} | insert the standard output of {command} below the cursor
|
||||
|
||||
|
||||
## Tabs
|
||||
|
||||
Status | Command | Description
|
||||
---|--------|------------------------------
|
||||
:warning: | :tabn[ext] :1234: | Go to tab page {count}. The first tab page has number one.
|
||||
:warning: | :tabp[revious] :1234: | Go to the previous tab page. Wraps around from the first one to the last one.
|
||||
:x: | :tabfir[st] | Go to the first tab page.
|
||||
:x: | :tabl[ast] | Go to the last tab page.
|
||||
|
56
src/cmd_line/commands/tab.ts
Normal file
56
src/cmd_line/commands/tab.ts
Normal file
@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
import * as vscode from "vscode";
|
||||
import * as node from "../node";
|
||||
import * as error from '../../error';
|
||||
|
||||
export enum Tab {
|
||||
Next,
|
||||
Previous,
|
||||
First,
|
||||
Last
|
||||
}
|
||||
|
||||
export interface ITabCommandArguments extends node.ICommandArgs {
|
||||
tab: Tab;
|
||||
range?: node.LineRange;
|
||||
}
|
||||
|
||||
//
|
||||
// Implements tab
|
||||
// http://vimdoc.sourceforge.net/htmldoc/editing.html#:quit
|
||||
//
|
||||
export class TabCommand extends node.CommandBase {
|
||||
protected _arguments : ITabCommandArguments;
|
||||
|
||||
constructor(args : ITabCommandArguments) {
|
||||
super();
|
||||
this._name = 'tab';
|
||||
this._shortName = 'tab';
|
||||
this._arguments = args;
|
||||
}
|
||||
|
||||
get arguments() : ITabCommandArguments {
|
||||
return this._arguments;
|
||||
}
|
||||
|
||||
execute() : void {
|
||||
switch (this._arguments.tab) {
|
||||
case Tab.Next:
|
||||
vscode.commands.executeCommand("workbench.action.nextEditor");
|
||||
break;
|
||||
case Tab.Previous:
|
||||
vscode.commands.executeCommand("workbench.action.previousEditor");
|
||||
break;
|
||||
case Tab.First:
|
||||
vscode.commands.executeCommand("workbench.action.openEditorAtIndex1");
|
||||
break;
|
||||
case Tab.Last:
|
||||
vscode.commands.executeCommand("workbench.action.openLastEditorInGroup");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
import {parseQuitCommandArgs} from './subparsers/quit';
|
||||
import {parseWriteCommandArgs} from './subparsers/write';
|
||||
import * as tabCmd from './subparsers/tab';
|
||||
|
||||
// maps command names to parsers for said commands.
|
||||
export const commandParsers = {
|
||||
@ -9,5 +10,10 @@ export const commandParsers = {
|
||||
write: parseWriteCommandArgs,
|
||||
|
||||
quit: parseQuitCommandArgs,
|
||||
q: parseQuitCommandArgs
|
||||
q: parseQuitCommandArgs,
|
||||
|
||||
tabn: tabCmd.parseTabNCommandArgs,
|
||||
tabp: tabCmd.parseTabPCommandArgs,
|
||||
tabfir: tabCmd.parseTabFirstCommandArgs,
|
||||
tabl: tabCmd.parseTabLastCommandArgs
|
||||
};
|
||||
|
29
src/cmd_line/subparsers/tab.ts
Normal file
29
src/cmd_line/subparsers/tab.ts
Normal file
@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
import * as node from "../commands/tab";
|
||||
import {Scanner} from '../scanner';
|
||||
import {VimError, ErrorCode} from '../../error';
|
||||
|
||||
export function parseTabNCommandArgs(args : string) : node.TabCommand {
|
||||
return new node.TabCommand({
|
||||
tab: node.Tab.Next
|
||||
});
|
||||
}
|
||||
|
||||
export function parseTabPCommandArgs(args : string) : node.TabCommand {
|
||||
return new node.TabCommand({
|
||||
tab: node.Tab.Previous
|
||||
});
|
||||
}
|
||||
|
||||
export function parseTabFirstCommandArgs(args : string) : node.TabCommand {
|
||||
return new node.TabCommand({
|
||||
tab: node.Tab.First
|
||||
});
|
||||
}
|
||||
|
||||
export function parseTabLastCommandArgs(args : string) : node.TabCommand {
|
||||
return new node.TabCommand({
|
||||
tab: node.Tab.Last
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user