9

When I do ^R on the terminal to reverse search, I get the following:

(^R) was pressed. Waiting for second key of chord...

How do I fix this? I'm on OS X.

4 Answers 4

15

Also see Run recent command as a replacement for reverse search from the v1.70 Release Notes:

When shell integration is enabled, we're aiming run recent command to be a cross-shell drop in replacement for the shell's reverse search (kbstyle(Ctrl+R)). There is a new contiguous search mode that is the default when triggering the command. This behaves like kbstyle(Ctrl+R) in most shells, with the option of switching back to fuzzy search:

terminal run recent search

The new inTerminalRunCommandPicker context key is available that allows setting up a keybinding like kbStyle(Ctrl+R) to go to the next match. For example, the following keybindings are now a fairly complete replacement for your shell's reverse search, with kbstyle(Ctrl+Alt+R) as a fallback to the old behavior:

{ "key": "ctrl+r",     "command": "workbench.action.terminal.runRecentCommand", "when": "terminalFocus" },
{ "key": "ctrl+alt+r", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\u0012"/*^R*/ }, "when": "terminalFocus" },
{ "key": "ctrl+r",     "command": "workbench.action.quickOpenNavigateNextInViewPicker", "when": "inQuickOpen && inTerminalRunCommandPicker" },
{ "key": "ctrl+c",     "command": "workbench.action.closeQuickOpen", "when": "inQuickOpen && inTerminalRunCommandPicker" },

Perhaps you actually want both! Terminal keybindings that are of the form

Ctrl+R Ctrl+something else

that is, keybindings that are chords AND still use

Ctrl+R (a non-chord keybinding) to trigger a reverse search in the terminal.

You can have both - add this keybinding to your keybindings.json:

  {
    "key": "ctrl+r",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "\u0012" },
    "when": "terminalFocus"
  },

That sends a "Ctrl+R" to the terminal and thus starts a reverse search. Even if you have other terminal keychords that starts with Ctrl+R, the terminal will not wait for the second part of a keybinding.

Note if you have a frequently used search you can add text to the command like:

    "args": { "text": "\u0012node" },

where it will already have started the search for commands with node in them.

2
  • Thank you! This is great if you want to keep CTRL+K chords enabled. Jul 8, 2020 at 14:24
  • Note that on OSX in order to use cmd you need to change "key": "ctrl+r", to "key": "cmd+r",
    – Nate Levin
    Mar 30, 2021 at 13:33
5

The setting that fixed it for me:

"terminal.integrated.sendKeybindingsToShell": true

When you make a clean vscode install, there will be a popup that explains what is going on with editor and terminal shortcuts. There you can configure your settings.

5

I realized that this started happening with me after I installed "Visual Studio Keymap" extension.

That is how I solved:

Ctrl + Shift + P for the command. There write: "Settings JSON" and select the option that says "Preferences: Open Settings (JSON)"

There, write the following setting:

"terminal.integrated.allowChords": false

Save and be happy

1
  • Attention: This will disable all your chords (like the CTRL+K + ... shortcuts) Jul 8, 2020 at 14:26
1

I used this when I had your same problem. It should work for OS X since it's just about key bindings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.