"Go to Definition" always in new tab in VSCode - visual-studio-code

I installed VSCode on MAC BigSur. Whenever I click on "Go to Definition" it should open in a new tab. How to achieve this?
Currently, only if the definition is present in another file, the definition opens in a new tab. Otherwise if present in the same file it scrolls to the definition in the same file which is not desired. In either case, function definitions should open in a new tab.

As written in the official documentation, you can open the definition to the side with Ctrl+Alt+Click.

Related

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.

Hide file drop down menu in editor

I'm working in VS Code and (I think I used a wrong shortcut) the following feature appeared: When having a file opened in a tab, there appears a bar below the header of the tab and above the first line of the file. When clicking on it, a dropdown menu opens up, where one can select the other files of the current folder (see picture below). When clicking on one of them, this file is opened in a new tab.
How can i remove this menu? I already searched through my user and workspace settings, but didn't find an appropriate option.
Picture
Thanks for your answers
You have enabled VSCode's breadcrumb feature. To disable it:
Press Ctrl+Shift+P to open the command pallete.
Type "Toggle Breadcrumbs" and press enter.
Alternatively, you can disable the breadcrumbs from the settings menu:

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

vscode: Go to definition in other editor pane

If I go to a definition of a function and the file is already open in another tab in the same editor pane, the definition will be shown there.
However, if the file is open in another editor split screen pane, the file will be opened again in the original editor.
Is it possible to change that behavior? Especially, if the file containing the definition is open in both panes (like when the definition of the function is in the same file where I call Go to definition), is there the possibility to jump to that definition in the other editor?
This is already a setting in version 1.35.1. Look for "Reveal If Open" in Settings (Workbench › Editor: Reveal If Open)
I believe that you are describing this issue
Should be fixed in VS Code 1.26+ (aka, the current VS Code insiders build)
there is also the editor.action.revealDefinitionAside command which will always open the file in another pane.

Eclipse - Can't View or Open Java files in Package Explorer to Editor

I clicked something or accidentally drug a file that was open in the editor and now it is no longer displayed.
If I double click on the file in Package Explorer it doesn't show in the editor like it used to. I have looked all over and can't figure out how to get this file back in the editor.
I thought clicking File - Open File would do it but that displays an open file dialog.
Another way to simulate this is to put the cursor in the editor for an open file and select File - Close. This closes the file but then if you double click on the file in the Package Explorer it doesn't open it in the editor anymore. How do I get these files to display in the editor again?
I also tried right clicking on the file and selecting "Open". This does not display in editor either.
I also tried right clicking and selecting "Open With Java Editor". This does not work either.
If I clicke "File" and then the name of the file in the MRU list . This does not work either.
Also, double clicking a file in Package Explorer fails to open any file. The file shows in the File MRU list but does not display in editor. Can not figure this out.
Also, if I select "Back to" or "Forward to" arrows on toolbar, it tracks the file in the Package Explorer by highlighting it but the file does not display in an editor like it used to.
Also, I have tried "File Open" browsing to the physical location and selecting it but that does not display in the editor either.
I had to open a new window (Window - New Window) and then Reset Perspective (Window - Reset Perspective) to get the editor back. Not sure why but I lost some of my perspective settings doing this.
In Package Explorer, instead of double-clicking on the file, try to right-click it and you should get several "Open with..." options; choose the one that matches the editor in which you want the file to open.
Your choice will also be saved as the default, so the next times you can just double-click and it will open in that same editor.
If you are customizing the perspective, then saving perspective could be a safer option to avoid such glitches.
PFB the link on how to save a perspective:
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2FgettingStarted%2Fqs-43e.htm