Skip to content

Commit

Permalink
Add gB keybinding for finding the previous match
Browse files Browse the repository at this point in the history
  • Loading branch information
musjj committed Apr 28, 2024
1 parent 0bab43f commit b18d18f
Showing 1 changed file with 21 additions and 0 deletions.
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

0 comments on commit b18d18f

Please sign in to comment.