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

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.

Related

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

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.

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.

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

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.

Eclipse: Get location of the current file?

If I've got a file open in Eclipse, how can I figure out where it is on the filesystem?
For example, in Vim I would use :pwd.
Use the Eclipse menu:
File->Properties
or the shortcut:
Alt-Enter
You should be able to see the Location associated with the Resource
Just hit Alt-Enter.
The other solution ("File-->Properties" or "Alt+Enter") didn't work for me.
I use:
Right Click (in current editor) --> Show In (shortcut: Alt+Shift+W) --> Project Explorer
This shows in Project Explorer the location of the file. If the file is a class in a referenced library, the dependency tree is automatically opened.
What you're looking for is the 'Properties' dialogue for the current file. This can be activated in two ways:
Selecting from the menu: File -> Properties
Using the shortcut: Alt + Enter
This gives you a dialogue which contains both the full path of the document, as well as the relative path from the workspace root.
The dialogue can be quite handy: it allows you to highlight and copy the file path.
Linking to Project Explorer won't work if you have many files - it will select the right file in the list, but it won't "scroll" to that portion so it is visible.
You'd have to manual scroll the Project Explorer view to see where the file is. It could also be nested so deeply that the full location will be obscured by truncation.
Another way to quickly (keyboard-free) see the path is to hover over the file type icon (on top of the open editor window).
Eclipse also has the ability to link the explorer view with the current file, so that whenever you change a file, it is expanded and selected in the explorer view.
Just look for the following image at the top of the view: