How to prevent VSCode from opening same file multiple times? - visual-studio-code

Assume you have index.js and service.ts in the side explorer. When I click on index.js, it opens in a view A. Then I open service.ts in a separate view B right to the first one and keep the focus in B and then click on index.js in the sidebar, it also opens in B. Can VS Code be configured such that instead of opening the file again, it switches to the already open one?
Additionally, if I really want the file open twice, I could open it a second time by double clicking it or dragging it to the view where it isnt present already.

If I understand correctly, try this setting set to true:
"workbench.editor.revealIfOpen": true,

Related

How do I get VS Code to stop replacing opened tabs with the one I'm trying to open?

Whenever I try to open a new file in a tab on my workspace instead of adding the tab to the workspace, it turns one of my opened tabs into that file. So I have 5 tabs open, and if I try to open a new file, it turns one of those 5 tabs into the file I'm trying to open.
How do I tell it to just open the file in a new tab? I'm going back and forth a lot and with a lot of files and folders to go through.It's really annoying to have to open a tab to check something, and then look through all the folders just to get back to what I was working on.
I tried looking through the settings but couldn't find anything useful.

How to run VS code on more than one monitor?

I'm still new to VS code and I saw this type of using VS code on two monitors, so I have 3 monitors and I'm on windows 10, I use the left one as a preview for the code I'm typing in chrome so that is sorted and I want my middle one to have the main code I'm working on and my right one is set vertically so I want it to run the terminal or of that file or another file so I can use both my right and middle to write code and I have no idea how can I do this.
there is a workaround, first in the file you want to open go and click ctrl+shift+p and search for open active file in new window, then in your new instance, press again ctrl+shit+p and search for Open User Settings(JSON) and add this line at the end of the settings "files.autoSave": "onFocusChange", so whenever you change windows the current file you're working on will be auto saved, hope this helps

VSCode Navigate Back local to current file only?

Is there an option in VSCode to limit "navigate back" such that it only takes you back to where you cursor was last in your current file?
This is the current behavior:
(On file A) open method foo
(On file A) open method bar
(On file B) open method baz
(On file A) open method bor
If I navigate back when I am on bor, my cursor will land on baz in file B.
Will it be possible to change this such that I land on bar in file A in stead?
From the issue cited below:
Added a new setting workbench.editor.navigationScope that can be
configured to editor to limit navigation actions such as "Go back"
and "Go forward" to the current active editor group.
workbench.editor.navigationScope
Should be in v1.65.
This functionality doesn't exist, see open issue: Have a history per editor for in-editor navigation.
However, in some cases like your simple example, Cursor Undo ,Ctrl+U, will work as you want. But it is pretty limited. Upvote the issue.

How to get rid of an empty panel in Visual Studio Code

I'm trying out Visual Studio Code. Yesterday, I opened a file outside of the git directory I was working in. I eventually moved and renamed the file and somewhere along the line, I ended up with the empty panel shown in the attached screenshot. I tried clicking every GUI element and every menu item and I could not get rid of it. I could close that file and it would go away, but once I re-opened it, it would come back, so it seemed to be associated specifically with that file.
I could split the view and add more tabs, but there was no way to get rid of it. I selected view > editor layout > single many times and it would not go away. All I could do was make it smaller by dragging the vertical divider.
This morning, I closed it and re-opened it, and it was gone. Unfortunately, despite trying to reproduce the steps that lead to that empty panel, I could not make that panel show up again.
Does anyone know what that panel was, why it was appearing with that file, and how to make it go away if it happens again?
That file basically shows you all the edits you've made since you last saved the file in git. By clicking on the source control button on the activity bar on the left side you can view your changes on the files you're working on. You can't actually edit it, it just shows the changes you've made.
To actually open the file and edit it you can either go back to the top left button called explorer on the activity bar or click on the little file button next to the name of the file (next to the + sign and the arrow).
Checkout this video by vscode which explains it

How to make sidebar visible by default?

In Visual Studio Code the sidebar is collapsed by default. I want to have the file list always visible.
Is there a setting for this?
When you open VS Code on a single file or via File | New Window the side bar is collapsed to focus on the editor area. As soon as you open a folder, the side bar will reveal the contents of the folder.
Currently there is no way to always show the side bar when opening a single file. To open the side bar, use the Ctrl+B (Mac: Cmd+B) key binding.
I don't have this behavior. If you exit VSCODE, VSCODE will save the visible state of the sidebar. Next time you open VSCODE, VSCODE will restore the saved visible state.