7

I disabled the activity bar (the leftmost panel with shortcuts buttons).

When I search for something the search results shown in side bar, replacing the file explorer. When I'm done with the search - how can I close the search results and see the file explorer bar again?

Given that there's no activity bar with the file structure bar shortcut on it? I tried clicking escape but the file results won't disappear. There's not even a button to close it.

Everett
  • 8,746
  • 5
  • 35
  • 49
Alex Craft
  • 13,598
  • 11
  • 69
  • 133
  • 1
    Ctrl-shift-E? Or right-click on activity bar to show the search icon again. It is a little unclear what you are asking. – Mark Jan 08 '19 at 06:41
  • 2
    Not sure why the question is unclear at all. It's perfectly obvious what Alexey is asking. – JakeJ Jun 03 '19 at 14:32

5 Answers5

12

After pulling up search with Cmd+Shift+F, I'm able to close with Cmd+B on Mac.

Alexander Terry
  • 129
  • 1
  • 2
11

I assume that you see something like this when you realize a search:

Search sidebar Visual Studio Code

You can go back to the Explorer sidebar on two different ways:

  1. Press in the File icon that is up of the Search icon
  2. Use the Ctrl+Shift+E shortcut
Inazense
  • 1,517
  • 3
  • 18
  • 28
6

This is a frustrating takeover of screen real-estate!

The UI for VSCode's search results pane aren't fully like a modal and they're not quite like a vertical tab. If you hover over the icons in the left-hand margin, you'll see the keyboard shortcuts for the "Explorer" and for "Search". On a Mac, it's Command + 1 to toggle the explorer and Command + 3 to toggle the search results.

However, toggling the explorer may not leave your screen the way it was before the search, so this isn't really the clean solution many of us were hoping for.

Here's a related question/answer with instructions for creating a key-binding.

The closest I have been able to come to the "expected behavior" I desire is to add the following rule to the top of my keybindings.json:

{
  "key": "Escape",
  "command": "workbench.view.explorer",
  "when": "searchViewletVisible"
}

The when clause helps scope its effect, but it may conflict with other commands.

Everett
  • 8,746
  • 5
  • 35
  • 49
  • 2
    Thanks! I've modified it though to enable this key binding only when search view is visible: `"key": "Escape", "command": "workbench.view.explorer", "when": "searchViewletVisible"` – sruzic Mar 12 '21 at 07:08
  • Nice -- I've updated my answer to include the `when` clause – Everett Mar 12 '21 at 14:28
2

In my case I wanted to close the sidebar when press Escape:

keybindings.json

{
    "key": "Escape",
    "command": "workbench.action.closeSidebar",
    "when": "sideBarFocus"
}

Resource

https://stackoverflow.com/a/64704130/5994546

serdarsen
  • 193
  • 2
  • 8
0

To close the search bar when using "Edit", "Find in Files" or "Replace in Files" in order to collapse the search results and/or panel I usually right-click on the "Search" label at the top of the results and click "Hide Side Bar" in the resulting drop down.

J Muldoon
  • 31
  • 1