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

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.

Related

How do I stop VSCode from revealing a file in the sidebar as soon as I click on it in "Source Control => Changes"

When I have a multiple file with changes in VSCode I often want to go trough the changes without staging.
I cannot do this because as soon as I click on one file with changes in "Source Control => Changes" the file is revealed in the sidebar and I have to navigate back to "Source Control" to review the changes of another file. In the past this wasn't the case. In order to open the file regularly (without diff) I could manually go to the Explorer and the file was selected.
When files are staged I can click on them and they will not be revealed in the sidebar. This behavior is what I would also like to have for files that are not staged.
What is causing this behavior (I use VSCode v1.74.2)? In the past this wasn't the case.
Update: This behavior is caused by an extension I need (Sigasi). They made an update and for some reason this caused the described unwanted behavior.
Hello from the Sigasi support department. ;)
The Sigasi extension for VS Code comes with a dedicated Project View to bring some useful Eclipse File System features to our VS Code extension.
One of the features this Project View offers, is to link the Project View with the editor in focus. This allows to quickly spot where you are in the project file hierarchy.
This feature can easily be disabled by going to the Project View and clicking the icon that controls the link with the editor. I'm linking a screenshot showing the link with editor setting.
It seems this feature at the moment is more intrusive than intended. We plan to adjust this feature so that it isn't active if the Project View is not visible or collapsed.

How to open files in new tabs in Visual Studio Code

I recently started using Visual Studio Code and I would like to know, is a way to open files in a new tab? Currently whenever I open a new file the files I currently have open disappear. I say new tab, but any option that will let me open a new file in the same window as the old one works.
I have tried disabling Preview Mode through the workbench settings as shown in this answer: How to config vscode to open files always in a new tab?. However, when I choose Open or Open Recent the new file still replaces my old file.
Thanks.
Once you have to open your settings file, add the "workbench.editor.enablePreview" property and set value to false.
For 1.21.1 version.
In user settings =>
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen"
the best way i found.
Starting with VSCode 1.52 (Nov. 2020), you should not have any more issue: all files will open in new tabs, even in preview mode.
Better handling of preview editors:
Preview editors are now better handled with numerous improvements based on feedback and making this feature work more consistent.
The setting workbench.editor.enablePreviewFromQuickOpen is now disabled by default so that editors opening from quick open will not appear in preview mode anymore.
When you start a navigation (e.g. go to definition), the editor you start from will move out of preview mode to keep it open while the new editor will be in preview mode until you navigate further.
We changed all of our custom trees (the ones used from extensions or Git changes view for example) to work more consistently like our built-in trees (like the explorer).
This means, the following interactions now apply to all of them:
double-click or mouse-middle-click to open non-preview
Enter to open non-preview (Space to open in preview-mode)
Note: if you are the author of an extension that is leveraging our custom tree API, you can benefit from this change as well.
Make sure to use vscode.open or vscode.diff commands for the TreeItem.command and you are in!
A new menu item in the editor overflow menu allows to quickly turn off preview editors altogether:
You need to double click on the name of the file. Also, it needs to be done swiftly elsewhere you will be opening in the same tab.
You can drag and drop file near to the opened tab and the file will open in new tab.
Thanks everyone. Double clicking and dragging was useful, but it still didn't solve my problem when opening files from different projects with the "Open File" menu command. I found that Multi-root Workspaces is what I was looking for. https://code.visualstudio.com/docs/editor/multi-root-workspaces
This is likely due to Visual Studio Code opening file in what's called "Preview Mode", which allows you to quickly view files, ideally if a tab is in Preview Mode then its title in the tab bar, will be italic.
To disable Preview Mode set "workbench.editor.enablePreview": false in your settings file or use the "workbench.editor.enablePreviewFromQuickOpen" option to disable it only from the quick open menu.
Alternatively, use command palette CTL+Shift+P (to get all settings) VScode settings then in User => Workbench => Editor Management you can uncheck Enable Preview and Enable Preview from Quick Open to get the same results described above

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)

Matlab Current Folder Tab automatically reflect open file

I would like the current folder tab to automatically update whenever I open a new .m file in the editor. So the current folder tab will always be open to the folder of the file being displayed in the editor. Is this supported in Matlab? I know Visual Studio has a feature like this.
MATLAB doesn't do that. Perhaps this might be close enough for you though: if you enable the Document Bar in the editor (if it's hidden, go Desktop menu->Document Bar->Bar Position->Select a Position). Now open a file in the editor. If you right-click on its element in the Document Bar, there's an option to change the current folder to the location of the file. So not automatic, but only one click away.