diff --git a/ROADMAP.md b/ROADMAP.md index ffdab160..8681a721 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -295,7 +295,7 @@ Status | Command | Description :white_check_mark: | :1234: J | join N-1 lines (delete EOLs) :white_check_mark: | {visual}J | join the highlighted lines :white_check_mark: | :1234: gJ | like "J", but without inserting spaces - | {visual}gJ | like "{visual}J", but without inserting spaces +:white_check_mark:| {visual}gJ | like "{visual}J", but without inserting spaces | :[range]d [x] | delete [range] lines [into register x] ## Copying and moving text diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 5f7c2fdb..b8c5c9d5 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -3017,6 +3017,32 @@ class ActionJoinNoWhitespace extends BaseCommand { } } +@RegisterAction +class ActionJoinNoWhitespaceVisualMode extends BaseCommand { + modes = [ModeName.Visual]; + keys = ["g", "J"]; + + public async exec(position: Position, vimState: VimState): Promise { + let actionJoin = new ActionJoinNoWhitespace(); + let start = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start); + let end = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.end); + + if (start.line === end.line) { + return vimState; + } + + if (start.isAfter(end)) { + [start, end] = [end, start]; + } + + for (let i = start.line; i < end.line; i++) { + vimState = await actionJoin.exec(start, vimState); + } + + return vimState; + } +} + @RegisterAction class ActionReplaceCharacter extends BaseCommand { modes = [ModeName.Normal];