How to disable file auto-focus in VSCode Explorer panel when file is opened by navigating tabs? - visual-studio-code

I wonder if there is a setting or a feature request should be submitted for the following:
Currently, if you pick a file from the project explorer, it goes into its own tab. If you have several tabs opened, as you focus any one of them, the file itself also gets focused in the project explorer.
For larger projects where you navigate through a lot of files in the project and open files here and there this could actually be a distraction - for some people it would be better not to focus the current file in the project explorer and not lose sight of the last file you actually opened and its neighbour-files.
Another scenario is when you debug a node.js app and need to debug repeatedly with F11 - a lot of times you could find yourself in some ultra-deep node_modules folder that takes over the whole project explorer - and you need to close this manually later to bring the project explorer to order.

To answer the first part, if you add this to your workspace or user settings, vscode will no longer automatically show the currently active file in the file explorer.
"explorer.autoReveal": false
To answer the second part, if you like to have the current file focused but you don't like having the explorer section expanded all over the place, there is a command that can help you. If you put something like this in your keybindings, then whenever you feel the explorer has become unruly you can use the keyboard command. It is also available in the command palette ("Files: Collapse folders in explorer") and there is an icon in the file explorer that looks like this: [-]
{
"key": "ctrl+shift+t",
"command": "workbench.files.action.collapseExplorerFolders",
"when": ""
}
I have also created an extension that can automate this.

You can use a param:
"explorer.autoReveal": "focusNoScroll"
Focus to file will not disabled, but it will work without scroll (that's clear from the param value). It is usefull sometimes.

Related

Is there a way to highlight the file I'm currently working on in the vscode explorer sidebar?

I have a lot of files in my root folder, and I'd like to be able to easily pinpoint where the current file is located in the VScode Explorer sidebar.
The "File: Reveal Active File in Side Bar" command is almost what I need: it opens the Explorer sidebar and highlights the current root folder with a blue box. However, the entire root folder is highlighted, not the specific file, so I still have to hunt for it amid all the other subdirectories and files in that tree.
Is there a command or set of commands I could use to achieve this? Alternately, is there a setting I could change that keeps the active file highlighted in the sidebar all the time? I'd just like some sort of indicator to see exactly where in the tree my active file is located.
add in settings.json
"workbench.colorCustomizations": {
"list.inactiveSelectionBackground": "#fffb17",
}
A small tip: in this picture:
please click "1" once, and then click "2" twice.
ctrl+shift+E
try it!
is there a setting I could change that keeps the active file highlighted in the sidebar all the time? I'd just like some sort of indicator to see exactly where in the tree my active file is located.
Was searching for this myself when I discovered the solution.
It sounds like what OP is looking for is Auto Reveal. Open your Settings: File > Preferences > Settings (or for a pc shortcut hold ctrl and press ,) and search for "explorer". Then under Explorer: Auto Reveal, select True or focusNoScroll.
With this option on, when you have multiple files open, each from different folders or projects, clicking on each tab (thereby making it the "active" file, which is what OP wanted) will automatically highlight the file in the Explorer column to the left of the editor.

VSCode: focus on file after clicking on it it in file explorer

I swear something has changed with VS code. You used to be able to click on a file in the file explorer, and it would automatically focus on the body of the file, so you can start typing immediately. Now, (1.36.1), when you click on a file in the file explorer, it stays focused on the file explorer, so if you start typing after clicking, it will start a search inside the explorer instead of the editor. This is extremely user hostile and I really want it disabled, it's totally throwing off my flow. How can I disable this?

Disable multiple "editors"? aka how do I fix my project explorer?

Currently whenever I open up a new file, from my understanding it's creating another editor with it's own instance of the project explorer.
I'm all for multiple editors, however it drives me nuts having multiple project explorers. (This equally drives me nuts in xcode). For me, ideally the project explorer would work the same way it does in Visual Studio. i.e. you open a new file into a new, what I will call "tab", and the state of the project explorer stays the same. If I scroll my project explorer, expand / collapse a directory and open a new tab, that explorer stays in the exact same state it was in.
Is that possible in VS Code? Is there a setting I'm missing? Thanks!
Try setting
"explorer.autoReveal": false
This should disable automatically revealing the active file in the explorer

VSCode: How to turn off auto select in File Explorer when changing window tabs?

In VSCode, if I have an editor window tab open and I click anywhere in that editor window, the selected file in the File Explorer changes to the file being edited. I would like to prevent that behavior. This is possible in Visual Studio, but I can't seem to find a similar setting in the preferences file of VSCode.
Can anyone provide some suggestions?
This has been added, see https://github.com/Microsoft/vscode/issues/14745.
Configuration is "explorer.autoReveal": false
You can't, at least not today. The only thing you can do, is keeping the scroll position when switching tabs. See this answer for the setting: VSCode prevent file Explorer from jumping
And here is the feature request on Github: https://github.com/Microsoft/vscode/issues/14745
(Feel free to add a "Thumbs Up" via Github Reaction at the top so the request gets more attention in the future, this increases the chances that it gets implemented sooner)

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

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?
The is an option explorer.autoReveal in settings (either user or workspace) which controls if the explorer should automatically reveal files when opening them.
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
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.
Save the User Settings file.
in Version: 1.42.1
Open VS User Settings (Preferences > User Settings).
Search for "explorer auto reveal" without quotes.
Now uncheck the checkbox.
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.