211

Is there a way to prevent VSCode from jumping all over the place when closing a tab? It jumps to the location of the selected tab, but this is very disorienting when opening various files to inspect within a lib.

Jacob Thomason
  • 3,062
  • 2
  • 17
  • 21

3 Answers3

358

This behaviour is controlled by the following setting in the settings.json file:

"explorer.autoReveal": false

File -> Preferences -> Settings:

enter image description here

There is currently no setting for keeping the selected file in the explorer, but this one at least keeps the scroll position fixed and prevents the "jumping".

Update

In current versions, the same setting now keeps the selected file.

Black
  • 18,150
  • 39
  • 158
  • 271
kwood
  • 9,854
  • 2
  • 28
  • 32
  • @Wosi That was my first thought, but it turns out that the answer is indeed correct. I just expected it to do a little more (keeping the selection). Answer edited, I add the issue we where talking about here in the comment section to keep context somewhat intact: https://github.com/Microsoft/vscode/issues/14745 (The VSCode team is moving so unbelievably fast with the project, the part with the "missing" piece might be obsolete soon anyway :) ) – kwood Oct 31 '16 at 09:37
  • 2
    shifted from sublime to vscode recently, glad this exists – BluePie Apr 10 '19 at 09:55
  • 3
    Unfortunately this controls the reveal behavior when both closing _and_ opening a file. It would be nice to have it reveal when you open a file only and not when you close one. – Jacob May 14 '21 at 18:08
  • 2
    Where to add this setting?? – Black Oct 13 '21 at 12:28
52

After you apply "explorer.autoReveal": false, as mentioned above, you can also set up

a shortcut to force show the current file in Explorer:

{ "key": "cmd+e", "command": "workbench.files.action.showActiveFileInExplorer" }
Vojtech Vitek - golang.cz
  • 25,275
  • 4
  • 34
  • 40
20

As commented in issue 23902 (Option to keep file selected in sidebar without forcing a scroll)

  • If set autoReveal to true, the jumping inside file explorer is confusing;
  • If set autoReveal to false, I have to use showActiveFileInExplorer keybinding or right click menu every time when switch between tabs

But with VSCode 1.46 (May 2020) you now have:

Explorer auto reveal focus without forcing a scroll

There is a new option focusNoScroll for the explorer.autoReveal setting.

When using this option, the Explorer will automatically select files when opening them but will not scroll to reveal them in the Explorer view.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250