Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gB keybinding for finding the previous match #9008

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2498,6 +2498,27 @@ class ActionTriggerHover extends BaseCommand {
}
}

@RegisterAction
export class ActionPreviousFindMatch extends BaseCommand {
modes = [Mode.Normal, Mode.Visual];
keys = ['g', 'B'];
override runsOnceForEveryCursor() {
return false;
}
override runsOnceForEachCountPrefix = true;

public override async exec(position: Position, vimState: VimState): Promise<void> {
await vscode.commands.executeCommand('editor.action.addSelectionToPreviousFindMatch');
vimState.cursors = getCursorsAfterSync(vimState.editor);

// If this is the first cursor, select 1 character less
// so that only the word is selected, no extra character
vimState.cursors = vimState.cursors.map((x) => x.withNewStop(x.stop.getLeft()));

await vimState.setCurrentMode(Mode.Visual);
}
}

/**
* Multi-Cursor Command Overrides
*
Expand Down