diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 1e2310e8254..6bcc22368f5 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -516,10 +516,20 @@ export class CommandInsertInInsertMode extends BaseCommand { const char = this.keysPressed[this.keysPressed.length - 1]; if (char === "") { - vimState.recordedState.transformations.push({ - type : "deleteText", - position : position, - }); + const selection = TextEditor.getSelection(); + + // Check if a selection is active + if (!selection.isEmpty) { + vimState.recordedState.transformations.push({ + type: "deleteRange", + range: new Range(selection.start as Position, selection.end as Position), + }); + } else { + vimState.recordedState.transformations.push({ + type: "deleteText", + position: position, + }); + } vimState.cursorPosition = vimState.cursorPosition.getLeft(); vimState.cursorStartPosition = vimState.cursorStartPosition.getLeft();