How do you include git ignored files in VSCode quick search - visual-studio-code

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

Related

Github incorrectly detects Languages of my project as "Roff"

In one of my repositories nearly all of my code is Python and some HTML.
However, Github thinks otherwise:
What causes that?
You were creating files through a script, with an unintended extension. That is, your script was inserting a dot in the file name.
Simply rename your file my_file_0.5ms to my_file_05ms.txt and it will display the correct languages:
What you could do to fix similar problems in the future is use a script to detect extensions and the total lines of code for each extension.
Solution
GitHub Linguist is the culprit in this situation, but luckily, it can be easily resolved in a number of ways.
Create a .gitattributes file and list patterns that match the files you want to ignore, and then append either linguist-vendored or linguist-documentation.
specific-file.5ms
*.5ms
specific-folder/*
This will remove the files from your GitHub repositories statistics on the next run of Linguist (it may take some time).
Notes
If you'd like to attribute these files to a specific language, you can do that using linguist-language={name}. Full documentation on overriding Linguist can be found here.
You can also run Linguist on your own computer, but note that any changes to .gitattributes will not take effect until you commit to your repository. Linguist will not see changes that exist only in the index.

VS Code: Search multiple directories

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.

Fast search in Visual Studio Code

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
},

.gitignore rules not working

I'm in the process of building a Lemonstand site, which I'm managing via git. As such, I'm using the following .gitignore rules:
# Lemonstand
.htaccess
php.ini
boot.php
index.php
install.php
/config/*
/controllers/*
/init/*
/logs/*
/phproad/*
/temp/*
/uploaded/*
/installer_files/*
/modules/backend/*
/modules/blog/*
/modules/cms/*
/modules/core/*
/modules/session/*
/modules/shop/*
/modules/system/*
/modules/users/*
# add content_*.php if you don't want erase client changes to content
/modules/gallery/*
/modules/lddevel/*
/modules/tweak/*
(The top block I got from github, with the second block being some additional rules I added myself to avoid issues with Lemonstands updating system).
My problem is that I'm adding a custom invoice to Lemonstand, which (to cut a long story short) requires the addition of a folder and some files within /modules/shop/invoice_templates/, which I've named cm_standard.
Because this is extra to the default Lemonstand, I want to get this tracked with git, so I'm trying to use the following rule to the bottom of my gitignore file:
!/modules/shop/invoice_templates/cm_standard/*
But when I do a git add -A, it isn't picking up the files within that directory. Even if I do a git add modules/shop/invoice_templates/cm_standard/* it tells me:
The following paths are ignored by one of your .gitignore files:
modules/shop/invoice_templates
Use -f if you really want to add them.
fatal: no files added
Which further suggests I've not written the rule correctly - can anyone help? Thank you.
Ignore patterns with fewer path segments can take precedence over patterns with more path segments, so in your case /modules/shop/* is taking precedence over !/modules/shop/invoice_templates/cm_standard/*, effectively pruning the whole of /modules/shop/invoice_templates/ from the directory traversal even before it looks at the contents of !/modules/shop/invoice_templates/cm_standard. Having said that, ordering can matter too, and when it does, somewhat counter-intuitively later rules within a file take precedence over earlier ones.
This question is very similar to How do gitignore exclusion rules actually work? so I suggest you read that. Also you may find the check-ignore subcommand useful when debugging rules - I added it to git over the last few months and it just appeared in version 1.8.2 which was released a few days ago.

Is there a way to get Eclipse's Open Resource dialog to search the middle of filenames automatically?

Eclipse's Open Resource dialog lets you search for project files based on a typed query, but the default behavior is to return only those filenames that start with the given query. You have to prepend a * wildcard symbol if you want the query to be interpreted as an arbitrary filename substring.
I'd say that 95% of the time, I'd want to prepend the wildcard. The default behavior for analogous dialogs, e.g. those in Visual Assist or Komodo, is to assume the query can be any part of the filename. I'm wondering if there's a way to force Eclipse to work the same way.
12+ years later, yes this is officially supported with Eclipse 4.27 (2023-03 release), from PR 12.
Open Resource dialog now defaults to "substring" search
By default, the search pattern input to the Open Resource dialog is now searched anywhere in the file name.
That means you no longer need to input a leading asterisk ("*") when searching from the middle of a file name.
If you want to enforce the old behavior, where "prefix-matching" search is expected, simply add a leading angle bracket (">") to the search pattern.
I don't think so. The UI you're talking about uses the FileDialog class which isn't really configurable in the way you describe. To me, that says that there's no preferences view that can alter that behavior. I certainly don't know of any nor could I find one.