I've been wanting to move from PhpStorm to VS code, but one of the things I don't like about VS Code is how slow its built-in Search feature is at finding text within the files of a large project.
PhpStorm is really good for this and, for me, is an essential feature. I can understand that PhpStorm is good at this because it is indexing all the files in the project beforehand.
Is there any way I can make VS Code search faster?
It may be as simple as telling VS Code not to index / search certain folders. Are there /vendor or /dist folders that you don't want to search through? Try this:
Do one of your slow searches
Look through the files that get returned
See if there are files being returned in a folder you don't care about
For each of these folders, add them to the files.exclude section of your settings file:
"files.exclude": {
"**/dist*": true,
"**/node_modules*": true
},
If there are any really large files that show up in the search, add those too.
The fewer files the search needs to deal with, the faster it will go.
Update Oct 2021
You should now use search.exclude instead of files.exclude, as files.exclude will remove the files from search, but will also remove the files from your file tree in the leftnav. search.exclude only filters them out of search.
"search.exclude": {
"**/dist*": true,
"**/node_modules*": true
},
Related
Working in PHP, my vendor folder is ignored by git.
If I press Command-P, how would I include ignored files in the quick search?
You can specify the state of inclusion for items in quick open using the following workspace (or otherwise) setting : search.exclude
Per their docs:
Configure glob patterns for excluding files and folders in fulltext searches and quick open. Inherits all glob patterns from the #files.exclude# setting
Edit: I interpreted what you were asking incompletely with my initial response, but will leave it for future question seekers and also because you can use in tandem with the following.
If you would like to make sure ignored files are present in quick open use one of the following, or both, depending on the scope of which it's ignored:
"search.useIgnoreFiles": false,
"search.useGlobalIgnoreFiles": false
When searching, VS Code has the ability to list files to include to scope the search. This is used by default when using the "find in folder" feature. For example, searching src results in ./src as the files to include.
Is there a syntax I can use to list multiple directories here? For example, I want to search ./src and ./lib in one search.
Did you try a comma like ./dir1, ./dir2? For me it seems to work
By the way, here is the documentation of 'files to include': https://code.visualstudio.com/Docs/editor/codebasics#_advanced-search-options
In particular, you can use glob notation. Also, VS Code will include/exclude certain directories or files by default, depending on your settings.json, in case anyone still sees unexpected behaviour.
At work there are a lot of file without extension. They are all COBOL files, so now I manually change their associating to COBOL each time I open one. But I was looking for a way to make VS Code treat files without extension as COBOL automatically.
I know you can add file associations in the settings, but the only thing that works is to add "*": "COBOL" there, but then everything is considered a COBOL file... I also tried `"[^.]": "COBOL" hoping regex would work but it didn't.
Is there a way to do this?
You can apply the file associations to all files in a given directory only:
"files.associations": {
"**/RootDir/**/*": "COBOL"
}
This way, all files in /RootDir/, or one of it's sub-directories, will be mapped to COBOL.
All files outside of /RootDir/ will still be mapped as usual according to their extensions.
Suppose your /RootDir/ doesn't contain only COBOL-files, but also some other file types. In this case you can go further and define exceptions for the file associations:
"files.associations": {
"**/RootDir/**/*.bat": "bat",
"**/RootDir/**/*.sh": "shellscript",
"**/RootDir/**/*": "COBOL"
}
Basically you're instructing Visual Studio Code to map all files in /RootDir/ to COBOL, except for .bat and .sh which are mapped as Batch and Shellscript, respectively.
As above, all files outside of /RootDir/ will still be mapped as usual according to their extensions.
I went through the same problem with php_cs-fixer config file.
This one is generally .php_cs.
I only have to add this line
"files.associations": {
"*.php_cs": "php"
},
AND relaunch vscode and .php_cs is now a php formatted file.
hope this help.
Just found another possible solution which works best for me.
I was trying to get shell lang selected for the .ssh/config and it worked by just adding
#!shellscript
at the very beginning of the file, maybe this doesn't work with all files/languages but it can be useful
Is it possible to exclude files from debugging in Eclipse?
There are my files which I have written and I am interesting in going through these files using debugger Step Over command.
But there are also many imported library files and Step Over goes into these files, which I'd like to avoid. So is there an option eother to specify which files to debug or which files to exclude?
If you're using a JVM based language (as you didn't specify), under Preferences, filter for Step Filtering.
You will see a list of packages. Add your packages to the list, and ensure Use Step Filters is selected.
Assuming it's an entire package you want filtered out, and you're using Java, this should do what you want.
Whenever i perform a file search in eclipse, it scans all files including .svn-base file.
Provided i am using * for file name patterns.
Is it possible to scan all files for searching but skipping the .svn-base file?
It is possible. But the search pattern is inclusive and not exclusive. You can click on Choose button and select the file types you wish to see in your search results.
You also have custom plugins for excluding .svn and .cvs directories during searches.
If you have Subclipse, the search filtering is included.
Note: since Eclipse Helios 3.6M3 (October 30, 2009), you can actually exclude resources from your project, making the search more precise as a result.
alt text http://download.eclipse.org/eclipse/downloads/drops/S-3.6M3-200910301201/images/resourceFilters.png