Hide or Show the Sidebar or the Activity Bar in VS Code

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
5 min

banner

# Table of Contents

  1. Hide or show the Sidebar using a keyboard shortcut in VS Code
  2. Using an icon to toggle the sidebar in VS Code
  3. Hide or show the Activity bar in VS Code
  4. Setting a different keyboard shortcut for toggling the sidebar
  5. Set a keyboard shortcut for toggling the Sidebar in settings.json
  6. Hide or show the Activity bar using settings.json
  7. Hide or Show the Activity Bar for the specific project

# Hide or show the Sidebar using a keyboard shortcut in VS Code

To hide or show the Sidebar in VS Code:

  • Press Ctrl + B on Windows and Linux
  • Press Cmd + B on macOS.

hide show sidebar

The keyboard shortcut toggles the sidebar:

  • Hides it if it is shown.
  • Shows it if it is hidden.

You can view the Toggle Sidebar Visibility keyboard shortcut in this section of the docs.

If you hover over the key combination, information for Windows, macOS and Linux is displayed.

You can also click on View in the top menu, hover over Appearance and select if the Primary Sidebar should be shown or hidden.

Note that you might have to press the Alt key to show the top menu on Windows and Linux.

view appearance toggle sidebar

I've also written an article on how to hide or show the minimap in VS Code.

# Using an icon to toggle the sidebar in VS Code

There is also an icon in the top bar that allows you to toggle the sidebar.

icon to toggle sidebar

Here is a short clip that demonstrates using the icon.

toggle sidebar using icon

# Hide or show the Activity bar in VS Code

The activity bar is to the left of the sidebar (where the icons are displayed).

If you need to hide or show the Activity Bar:

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type activity bar and select View: Toggle Activity Bar Visibility.

view toggle activity bar

You can also right-click on the Activity bar and select Hide Activity Bar to hide it.

Alternatively, you can use the top menu to hide or show the Activity Bar:

Click on View -> Appearance and then Activity Bar.

Note that you might have to press Alt to show the top menu on Windows and Linux.

hide show activity bar using top menu

# Setting a different keyboard shortcut for toggling the sidebar

If you want to set a different keyboard shortcut for the Toggle Sidebar Visibility action:

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Keyboard Shortcuts and select Preferences: Open Keyboard Shortcuts.

preferences open keyboard shortcuts

  1. Type toggle sidebar and double-click on the View: Toggle Primary Side Bar Visibility row.

set new keyboard shortcut to toggle sidebar

  1. Specify a keyboard shortcut for the action and press Enter to confirm.

If you need to set a keyboard shortcut for hiding or showing the Activity Bar, type toggle activity in the search field and double-click on View: Toggle Activity Bar Visibility.

set keyboard shortcut toggle activity bar

You can also click on the plus icon, specify your preferred key combination and press Enter.

# Set a keyboard shortcut for toggling the Sidebar in settings.json

If the Ctrl + B keyboard shortcut may be overridden by VIM or another extension.

You can also set the keyboard shortcut directly in your settings.json file if you want to enforce it.

The name of the command is workbench.action.toggleActivityBarVisibility.

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type Keyboard Shortcuts and select Preferences: Open Keyboard Shortcuts.

preferences open keyboard shortcuts

  1. Click on the Open Keyboard Shortcuts (JSON) icon to the left.

open keyboard shortcuts

  1. Add the following object to your keybindings.json file.
keybindings.json
{ "key": "ctrl+b", "command": "workbench.action.toggleSidebarVisibility" },

You can also set the keyboard shortcut to cmd+b if you are on macOS.

set ctrl b keyboard shortcut

# Hide or show the Activity bar using settings.json

You can also set the visibility of the activity bar globally, in a settings.json file.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings json.

  2. Click on Preferences: Open User Settings (JSON)

preferences open user settings

  1. Set the following property.
settings.json
"workbench.activityBar.visible": false

If the property is set to false, the activity bar is hidden.

If you want to show the activity bar, set the property to true.

settings.json
"workbench.activityBar.visible": true

set activity bar visible

# Hide or Show the Activity Bar for the specific project

You can also hide or show the activity bar for the specific project, in a local settings.json file:

  1. In the root directory of your project, create a .vscode folder.

  2. Create a settings.json file in the .vscode folder.

  3. Add the following code to your settings.json file.

.vscode/settings.json
{ "workbench.activityBar.visible": true }

If you want to hide the activity bar, set the property to false.

.vscode/settings.json
{ "workbench.activityBar.visible": false }

set activity bar visibility in vscode settings json

If you need to hide specific files or folders from the left sidebar, click on the following link.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.