How to find folder in VS Code? - visual-studio-code

I have a project with a lot of files and folders. There are no problems with finding files. They can be found with Ctrl-P. But there are many folders in which files with the same name are made. Therefore, it is easier to search for a file by the name of the folder in which it is located. How in VS Code to search for folders in the current open project?
For example, I have the following project structure:
A/
main.js
B/
main.js
...
Z/
main.js
The file main.js from the folder P will be easier to find by the folder name.

While using Ctrl-P, you can type the full path of the file, so if i have two files named bar you can search on Ctrl-P with
"foo/bar" or with "qux/bar"
Vscode uses fuzzy search (like so many others), so you don't have to actually type the whole thing.
There is no way, to my knowledge and research, to find and be directed to a specific directory.

You can simply select a folder on the explorer and tape some filter keywords.
Recently, vscode added a shortcut, if you are using a recent release just typing won't work, first tape ctrl + f.

Ctrl + Shift + E
and start typing. You'll see your search on the top right corner of file explorer.
By default it does not filter by result but your focus will jumps to the first one. From there you can Enter to open it.
If you want to show only results containing the string of search : click on filter icon next to your search (state will be remembered).
Echap
to exit/remove search
or
Ctrl + Shift + E
again to switch back focus to last place you were typing.

This VSCode extension does exactly what you're asking for.
https://marketplace.visualstudio.com/items?itemName=rwu823.open-folder

I found a way to search through subfolders. Click on a folder you wish to search, than / and start typing for a name of subfolder

It's simple. Just open the parent folder of your folder in VSCode. Then right-click on the folder you want to find subfolder in and choose "Find in folder"

Related

Is there any way in vscode to know where the current the file has been imported?

Are there any extensions/features in vs-code which could let me know where the current file is imported? I usually do a global search of the filename but it is time consuming when the file name is similar to any variable or there are similar named files.
You can do a right-click on every function / variable or class. Then you choose "Find all references" to show where each function / variable or class is called.
For this you do not need an extension, because it is a standard feature of vscode
- find unused exports in project:
you can use this extension in vscode to find all unused exports
+ find name references (e.g. used exports) in project:
click on name then press shift+alt+F12
NO EXTENSION REQUIRED
Yes, We can find the references of a file in VSCODE like this:
Right-click on the file and then select Find References.
VSCODE will show all the references/imports of the file.
image reference
Right-click > Go to References (Shift + F12)
There is also an extension to change the appearance of how references show https://marketplace.visualstudio.com/items?itemName=jrieken.references-plusplus
If you are limiting your search to the current open workspace / folder, you can
do a search for 'import' using the magnifying glass or pressing ctrl+shift+s
open the results in editor by either clicking the link that says 'Open in editor' or by pressing alt+enter
In the document that opens, search for the name of your module.
In this way you will discover all of the imports that involve your module, regardless of whether you have used 'import mymodule' or 'from mymodule import myfunction' or anything else. I'm specifically thinking of how I'd structure a python project, but if you are using another language, you can alter the search in a way that works for the way your language does imports.

Show more path in vscode tabs [duplicate]

I've got a component-based folder structure in my project. It is a bunch of component-folders with one index.js file each.
Is it possible to make Visual Studio Code display the parent folder name in the file tabs? Or am I limited to seeing a bunch of tabs that all display index.js and nothing else?
You can configure Visual Studio Code to always show parent folder names in the tabs! In your User Settings, just add this line: "workbench.editor.labelFormat": "short" (other values are "long", "medium" or "default")
Result: the files init/views.js, init/routes.js and plugins/modal.js will be presented as such:
Another option is the User Setting "breadcrumbs.enabled": true which will give you an entire row of breadcrumbs showing the complete file path:
PS: To open User Settings use the File-menu → Preferences → Settings → User Settings. To view the settings in a JSON format just click the {} icon in the top right corner.
Go to the main menu File → Preferences → Settings. And search for (Cmd + F on Mac; Ctrl + F on Windows and Linux) workbench label format.
Choose the short option.
Visual Studio Code has now improved their tab-UI to resolve this issue.
When you've opened multiple tabs with the same filename, Visual Studio Code will automatically display the parent foldername in each of those tabs.
Here's an example: I've opened event.js and two index.js files. Visual Studio Code automatically decides it's a good idea to display the foldername for the index.js files :)
It pretty much solved the bulk of my problem.
I know this is too late to answer, but in case someone is looking for the file path to show on the title bar, you can follow this:
Open settings (command + ,)
Search for title
You'll see something like activeEditorShort, replace it with activeEditorLong
Save
Source:
https://medium.com/riow/vscode-show-full-path-in-title-bar-b0cb731b330
Step 1: Go to File > Preferences > Settings
Step 2: search for "workbench.editor.labelFormat"
Step 3: select medium from a drop-down
You can install the nice-index extension for a better experience dealing with index files.
However, as of now, it only works when you have more than one index file open. This can be resolved by changing labelFormat to "short", as other answers suggest.
In VSCode 1.53 you can use thees settings:
Controls the window title based on the active editor. Variables are substituted based on the context:
${activeEditorShort}: the file name (e.g. myFile.txt).
${activeEditorMedium}: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).
${activeEditorLong}: the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt).
${activeFolderShort}: the name of the folder the file is contained in (e.g. myFileFolder).
${activeFolderMedium}: the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder).
${activeFolderLong}: the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder).
${folderName}: name of the workspace folder the file is contained in (e.g. myFolder).
${folderPath}: file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder).
${rootName}: name of the opened workspace or folder (e.g. myFolder or myWorkspace).
${rootPath}: file path of the opened workspace or folder (e.g. /Users/Development/myWorkspace).
${appName}: e.g. VS Code.
${remoteName}: e.g. SSH
${dirty}: a dirty indicator if the active editor is dirty.
${separator}: a conditional separator (" - ") that only shows when surrounded by variables with values or static text.

Showing path in file-tabs in Visual Studio Code

I've got a component-based folder structure in my project. It is a bunch of component-folders with one index.js file each.
Is it possible to make Visual Studio Code display the parent folder name in the file tabs? Or am I limited to seeing a bunch of tabs that all display index.js and nothing else?
You can configure Visual Studio Code to always show parent folder names in the tabs! In your User Settings, just add this line: "workbench.editor.labelFormat": "short" (other values are "long", "medium" or "default")
Result: the files init/views.js, init/routes.js and plugins/modal.js will be presented as such:
Another option is the User Setting "breadcrumbs.enabled": true which will give you an entire row of breadcrumbs showing the complete file path:
PS: To open User Settings use the File-menu → Preferences → Settings → User Settings. To view the settings in a JSON format just click the {} icon in the top right corner.
Go to the main menu File → Preferences → Settings. And search for (Cmd + F on Mac; Ctrl + F on Windows and Linux) workbench label format.
Choose the short option.
Visual Studio Code has now improved their tab-UI to resolve this issue.
When you've opened multiple tabs with the same filename, Visual Studio Code will automatically display the parent foldername in each of those tabs.
Here's an example: I've opened event.js and two index.js files. Visual Studio Code automatically decides it's a good idea to display the foldername for the index.js files :)
It pretty much solved the bulk of my problem.
I know this is too late to answer, but in case someone is looking for the file path to show on the title bar, you can follow this:
Open settings (command + ,)
Search for title
You'll see something like activeEditorShort, replace it with activeEditorLong
Save
Source:
https://medium.com/riow/vscode-show-full-path-in-title-bar-b0cb731b330
Step 1: Go to File > Preferences > Settings
Step 2: search for "workbench.editor.labelFormat"
Step 3: select medium from a drop-down
You can install the nice-index extension for a better experience dealing with index files.
However, as of now, it only works when you have more than one index file open. This can be resolved by changing labelFormat to "short", as other answers suggest.
In VSCode 1.53 you can use thees settings:
Controls the window title based on the active editor. Variables are substituted based on the context:
${activeEditorShort}: the file name (e.g. myFile.txt).
${activeEditorMedium}: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).
${activeEditorLong}: the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt).
${activeFolderShort}: the name of the folder the file is contained in (e.g. myFileFolder).
${activeFolderMedium}: the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder).
${activeFolderLong}: the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder).
${folderName}: name of the workspace folder the file is contained in (e.g. myFolder).
${folderPath}: file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder).
${rootName}: name of the opened workspace or folder (e.g. myFolder or myWorkspace).
${rootPath}: file path of the opened workspace or folder (e.g. /Users/Development/myWorkspace).
${appName}: e.g. VS Code.
${remoteName}: e.g. SSH
${dirty}: a dirty indicator if the active editor is dirty.
${separator}: a conditional separator (" - ") that only shows when surrounded by variables with values or static text.

Searching a string in eclipse workspace

How to search for a string in the complete eclipse workspace?
I was not able to locate a text in the eclipse workspace however I could not find the specified string in the workspace.
At the top level menus, select 'Search' -> 'File Search' Then near the bottom (in the scope) there is a choice to select the entire workspace.
For your "File search has encountered a problem", you need to refresh the files in your workspace, in the Project/Package Explorer, right click and select "Refresh" at any level (project, folder, file). This will sync your workspace with the underlying file system and prevent the problem.
Press Ctrl + H, should bring up the search that will include options to search via project, directory, etc.
Ctrl + Alt + G can be used to find selected text across a workspace in eclipse.
Ctrl+ H, Select "File Search", indicate the "file name pattern", for example *.xml or *.java. And then select the scope "Workspace"
Eclipse does not search if the "File name patterns" field is empty.
So, if you want to search some text, write within "Containing text" field
and leave by default "File name patterns" with asterisk (*).
A lot of answers only explain how to do the search.
To view the results look for a search tab (normally docked at the bottom of the screen):
eclipse instasearch plugin is a very useful plugin for search needs inside eclipse.
It is based on lucene. This is also available in eclipse marketplace.
It has extensive feature set.
Instantly shows search results
Shows a preview using relevant lines
Periodically updates the index
Matches partial words (e.g. case in CamelCase)
Opens and highlights matches in files
Searches JAR source attachments
Supports filtering by extension/project/working set
For Mac:
Quick Text Search: Shift + Cmd + L
All other search (like File Search, Git Search, Java Search etc): Ctrl + H
Goto Search->File
You will get an window, you can give either simple search text or regx pattern. Once you enter your search keyword click Search and make sure that Scope is Workspace.
You may use this for Replace as well.
Press Ctrl+shift+L and type your string
In your Eclipse editor screen, try Control + Shift + R buttons.

Search in Eclipse through project

How to search in Eclipse through project for some word ? When I start CTRL-h I need to choose field, method or ...., but I need to find all occurences in project no metter method, field or .. ! How to achieve that ?
CTRL + H -> File Search -> Containing Text 'some word'
make sure the scope is set to workspace or enclosing projects. Choosing Selected Resources will narrow the result set to the folder or file you selected in the explorer.
Further if you know the file type that might contain the text you can use the File Name patterns with values like *.php, *.phtml, *.html
Ctrl + Alt + G might help finding Text in the new Version of Eclipse 3.7.
In order to accomplish it you need to customize your research:
Ctrl + H
then at the bottom of the search window click on Customize
check only FileSearch and unselect the rest of the options
then you can search for anywork in the project by selecting either worksapce or Enclosing project
If you are using InstaSearch Eclipse plugin you can easily filter searches by project:
proj:MyProjectName textToFind
or use ui to select a project to search in.