How do I stop VSCode from the Side Bar moving to the folder that the current file is in?

Visual Studio-Code

Visual Studio-Code Problem Overview


In Visual Studio Code, whenever I close a file, the next open file becomes active in the editor and the Side Bar moves to that file's location in the folder structure. This is usually not the behavior I want. I often want to open another file in the same location as the one I just closed, but now my Side Bar has shifted around to what could be a totally different place in a large project.

I like the behavior of the main Visual Studio product where the Solution does not automatically shift. Instead, if I want to see where in the solution a file is, I can use a keyboard shortcut to move there ("Find File in Solution"), instead of automatically moving there every time the active file changes.

Is there any way to change/disable this functionality in VSCode?

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

The is an option explorer.autoReveal in settings (either user or workspace) which controls if the explorer should automatically reveal files when opening them.

  1. Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
  2. Add a new "explorer.autoReveal": false setting to the User Settings document on the right if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it.
  3. Save the User Settings file.

Solution 2 - Visual Studio-Code

in Version: 1.42.1

  1. Open VS User Settings (Preferences > User Settings).
  2. Search for "explorer auto reveal" without quotes.
  3. Now uncheck the checkbox.

Uncheck this

Solution 3 - Visual Studio-Code

There is a new setting in v1.46 that will select the files in the explorer but not scroll to reveal them:

> We have introduced a new value focusNoScroll to the > explorer.autoReveal setting. For this value Explorer will > automatically select files when opening them but will not reveal them.

from v1.46 release notes.

So that setting will highlight the active editor in the explorer but not scroll to it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarkView Question on Stackoverflow
Solution 1 - Visual Studio-CodembernardeauView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeAli RazaView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeMarkView Answer on Stackoverflow