Does VSCode have a hotkey/shortcut for "toggle replace", switching between "find" and "replace" mode
Asked Answered
G

3

5

Visual Studio Code has a search and replace widget with a little dropdown button that toggles between one-line search mode and two-line replace mode. If you hover the pointer over it there's a tooltip saying "Toggle Replace".

search mode replace mode

Almost every function I've ever wanted a hotkey for in VSCode has had one, and I can find them by looking in the View/Command Palette... menu. But there doesn't seem to be a hotkey for this one. Unless it's confusingly named or perhaps built-in and hence not listed?

I am aware that there are separate keys for "Find" and "Replace" and that the first one takes me to the top line or only line if the box is in "Find mode" and the second takes me to the bottom line, and puts the box in "Replace mode" if it is currently in "Find mode".

But sometimes I just want it to be back in Find mode when I don't intend to do any replacing, but I want to do it without having to use mouse/trackpad since I touchtype and my fingers are on the keyboard.

I know I don't need it but I keep wanting it. I know it's very minor.

Is there a way to put the Find and Replace widget back into single-line "Find" mode from the keyboard?

(I'm using the Mac version if that makes any difference.)

Gogh answered 23/6, 2022 at 13:18 Comment(13)
from Find to Replace is Ctrl+H and Ctrl+F moves back to find boxKerbing
@Kerbing that doesn't work for me. I'm on Mac and added that to the question.Gogh
When I do what rioV8 suggests, it doesn't toggle the lines as the question wants. It just moves the focus around. Helpful, but not quite what is being asked for.Clermontferrand
@TimothyG. for me I thought it did nothing, but it seems to be same as backspace. I haven't got it to affect focus yet.Gogh
This is what I mean - i.sstatic.net/BJnxU.gifClermontferrand
Interesting. I can't reproduce that.Gogh
replace Ctrl with CmdKerbing
@Kerbing already tried that. It's a standard Mac shortcut to hide the current app.Gogh
What is the Replace command bound to in your Keyboard Shortcuts? Use that instead of Cmd+H if that is bound to something else. It toggles focus back and forth - same command - between the Find and Replace inputs. Yes, it doesn't close the Replace input, but it is the same single keybinding, no reversing steps, just one step.Saccharoid
@Mark: Ah yes. It's F and it does indeed work as rioV8 describes.Gogh
I can just keep hitting Ctrl+H (or option+command+F for you) to toggle focus between the two inputs. You don't need to switch between Ctrl+F and Ctrl+H.Saccharoid
oops yes I meant it's as @TimothyG. describes (-:Gogh
the function of the dialog by pressing Enter depends on the box your in, it is not what is visible, see the when clause in the keybind dialog for functions of EnterKerbing
C
9

From the keyboard, yes. If you use your Tab, Shift and Enter keys (Space also works instead of Enter), you can control this window. Note the blue outline around the selected control.

When you first open the Find box, it is focused in the text field of the text you want to find. If you do Shift + Tab, it will move the focus to the arrow that toggles the replace line. Simply press Enter and you can open the replace textbox line. You can basically do this in reverse to then toggle the replace line to be hidden again.

enter image description here

Clermontferrand answered 23/6, 2022 at 13:35 Comment(4)
Nice! Space works as well as Enter too.Gogh
How did you go to the replace text field?Camara
@Camara once you expand the find box to show the Replace field (meaning you should be focused on the symbol), just hit tab twice.Clermontferrand
Not seeing the blue outline? Your theme might have it hidden/disabled. So you may have execute shift + tab blind. It still works though. (I use the "Material Theme Darker High Contrast" which doesn't show focus rings.)Flavoring
Q
1

When you first open the Find box, it is focused in the text field of the text you want to find. If you are using a mac do Shift + option + Tab, it will move the focus to the arrow that toggles the replace line.

Quassia answered 15/8, 2022 at 14:15 Comment(0)
R
0

Select the text you want to replace via keyboard, press Ctrl+H

Regin answered 9/9 at 7:16 Comment(2)
On macOS Ctrl+H behaves identically to the backspace key.Gogh
This doesn't answer the question of getting the Find and Replace control back into just the "Find" mode. All CTRL + H does is open the control in the Find and Replace mode instead of just find.Clermontferrand

© 2022 - 2024 — McMap. All rights reserved.