nz_21
nz_21

Reputation: 7403

vs-code: unable to reverse search on built-in terminal

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.

Upvotes: 16

Views: 7550

Answers (5)

tomlopaton
tomlopaton

Reputation: 1

I had to add these lines to settings.json [Ctrl+Shift+P > Settings(Json)]:

"terminal.integrated.allowChords": false,
"terminal.integrated.sendKeybindingsToShell": true

Upvotes: 0

Francisco Cardoso
Francisco Cardoso

Reputation: 1978

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

Upvotes: 11

Mark
Mark

Reputation: 182881

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.

Upvotes: 24

tonisives
tonisives

Reputation: 2528

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.

Upvotes: 9

sNok3
sNok3

Reputation: 101

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

Upvotes: 1

Related Questions