diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 7a89aaab1d9..37586a2e24d 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -4504,6 +4504,15 @@ class ActionReplaceCharacter extends BaseCommand { let timesToRepeat = vimState.recordedState.count || 1; const toReplace = this.keysPressed[1]; + /** + * includes , and but not any control keys, + * so we ignore the former two keys and have a special handle for . + */ + + if (['', ''].indexOf(toReplace.toUpperCase()) >= 0) { + return vimState; + } + if (position.character + timesToRepeat > position.getLineEnd().character) { return vimState; } @@ -4520,14 +4529,25 @@ class ActionReplaceCharacter extends BaseCommand { endPos = new Position(endPos.line, endPos.character + 1); } - vimState.recordedState.transformations.push({ - type : "replaceText", - text : toReplace.repeat(timesToRepeat), - start : position, - end : endPos, - diff : new PositionDiff(0, timesToRepeat - 1), - }); - + if (toReplace === '') { + vimState.recordedState.transformations.push({ + type: "deleteRange", + range: new Range(position, endPos) + }); + vimState.recordedState.transformations.push({ + type: "tab", + cursorIndex: this.multicursorIndex, + diff: new PositionDiff(0, -1) + }); + } else { + vimState.recordedState.transformations.push({ + type : "replaceText", + text : toReplace.repeat(timesToRepeat), + start : position, + end : endPos, + diff : new PositionDiff(0, timesToRepeat - 1), + }); + } return vimState; } diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index af7c14e8066..17a7ca3b75a 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -1374,6 +1374,21 @@ export class ModeHandler implements vscode.Disposable { return vimState; } break; + case "tab": + await vscode.commands.executeCommand('tab'); + if (command.diff) { + if (command.cursorIndex === undefined) { + throw new Error("No cursor index - this should never ever happen!"); + } + + if (!accumulatedPositionDifferences[command.cursorIndex]) { + accumulatedPositionDifferences[command.cursorIndex] = []; + } + + accumulatedPositionDifferences[command.cursorIndex].push(command.diff); + } + + break; } } diff --git a/src/transformations/transformations.ts b/src/transformations/transformations.ts index 8b118f9fe9d..c5ac7508193 100644 --- a/src/transformations/transformations.ts +++ b/src/transformations/transformations.ts @@ -192,6 +192,19 @@ export interface Dot { type: "dot"; } +/** + * Represents Tab + */ +export interface Tab { + type: "tab"; + cursorIndex?: number; + + /** + * Move the cursor this much. + */ + diff: PositionDiff; +} + /** * Represents macro */ @@ -211,7 +224,8 @@ export type Transformation | ShowCommandLine | Dot | Macro - | DeleteTextTransformation; + | DeleteTextTransformation + | Tab; /** * Text Transformations