mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-08-17 00:00:26 +03:00
Join lines in visual mode
This commit is contained in:
parent
231f3da1d0
commit
b2f0cb8d50
@ -252,8 +252,8 @@ Status | Command | Description | Note
|
||||
:warning: | NL or CR or CTRL-M or CTRL-J | begin new line | CTRL-M and CTRL-J are not supported yet
|
||||
:white_check_mark: | CTRL-E | insert the character from below the cursor
|
||||
:white_check_mark: | CTRL-Y | insert the character from above the cursor
|
||||
| CTRL-A | insert previously inserted text
|
||||
| CTRL-@ | insert previously inserted text and stop Insert mode
|
||||
:running: | CTRL-A | insert previously inserted text
|
||||
:running: | CTRL-@ | insert previously inserted text and stop Insert mode
|
||||
:white_check_mark: | CTRL-R {0-9a-z%#:.-="} | insert the contents of a register
|
||||
:arrow_down:| CTRL-N | insert next match of identifier before the cursor
|
||||
:arrow_down:| CTRL-P | insert previous match of identifier before the cursor
|
||||
@ -293,7 +293,7 @@ Status | Command | Description
|
||||
:white_check_mark: | :1234: dd | delete N lines
|
||||
:white_check_mark: | :1234: D | delete to the end of the line (and N-1 more lines)
|
||||
:white_check_mark: | :1234: J | join N-1 lines (delete EOLs)
|
||||
| {visual}J | join the highlighted lines
|
||||
: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
|
||||
| :[range]d [x] | delete [range] lines [into register x]
|
||||
|
@ -2954,6 +2954,32 @@ class ActionJoin extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterAction
|
||||
class ActionJoinVisualMode extends BaseCommand {
|
||||
modes = [ModeName.Visual];
|
||||
keys = ["J"];
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<VimState> {
|
||||
let actionJoin = new ActionJoin();
|
||||
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 ActionJoinNoWhitespace extends BaseCommand {
|
||||
modes = [ModeName.Normal];
|
||||
|
Loading…
Reference in New Issue
Block a user