vscode: how to change the hotkey of 'replace' and 'next match'

Viewed 273

In the replace mode of vscode:

enter image description here

The hotkeys of 'go to next match' and 'replace' are both enter.

I want to selectively replace some words. For example, in the lower part of the image: I want to rename hidden_dim' but not hidden_dim_in`.

Hitting the key enter will repeatedly do either 'go to next match' or 'replace'. How could I set different hotkeys for these two functions?

2 Answers

Inspired by @amordo's answer, I find an easier way to "go to next match" while replacing words in vscode:

F3

The F3-key is the default setting of vscode for finding next, which works properly during replacing.

enter image description here

Ps. the Shift + Enter short cut, doesn't help in this case. It will add a new line.enter image description here

I've added a new shortcut to keybindings.json Command Palette -> Preferences: Open Keyboard Shortcuts (JSON):

{
    "key": "shift+cmd+enter",
    "command": "editor.action.nextMatchFindAction",
    "when": "editorFocus && replaceInputFocussed"
}

Another way is to Add Keybinding... based on 'go to next match' (Find Next) shortcut in Preferences: Open Keyboard Shortcuts and change it via UI. enter image description here

Now using a new shortcut with replace window focused you go to the next match; press enter to replace that.enter image description here

Related