Add comment operator 'gb'.

This commit make it possbile to use 'gb' to toggle line comments.
This commit is contained in:
Kim Fiedler Vestergaard 2017-04-13 14:33:39 +02:00
parent fe9a6cc875
commit bd780205a2

View File

@ -7050,3 +7050,19 @@ class CommandSurroundAddToReplacement extends BaseCommand {
return false;
}
}
@RegisterAction
export class CommentOperator extends BaseOperator {
public keys = ["g", "b"];
public modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine];
public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
vimState.editor.selection = new vscode.Selection(start.getLineBegin(), end.getLineEnd());
await vscode.commands.executeCommand("editor.action.commentLine");
vimState.cursorPosition = new Position(start.line, 0);
vimState.currentMode = ModeName.Normal;
return vimState;
}
}