I have to "look in:" a subfolder of the project because the entire project is very large and takes too long to search through.
I also have AnkhSVN installed and wonder if a setting in the plugin could help too.
If you use "Find in files" instead of the standard search, you can search a subfolder for file types you specify.
However, it's a lot easier to perform this kind of task using the Ultrafind add-on (http://visualstudiogallery.msdn.microsoft.com/9fa9fdd7-1c06-45e3-a9f3-0381caab8f94) which you can use to exclude specific file patterns.
Sadly, it seems that despite all the wonderful functionality of Visual Studio, the easiest way to omit .svn directories from searches is to use Windows Explorer to navigate to the .svn directory, right click the folder, go to Properties, and click the Hidden checkbox under Properties.
If you then re-open your Visual Studio solution, it should keep those files out of the searches.
A quick and dirty way is to simply include every other file type except .svn and .svn-base etc.
Try using this set of wildcards and add any other valid extensions beginning with S that you might need:
*.sql;*.svc;*.;*.?;*.??;*.a??;*.a???;*.a????;*.b??;*.b???;*.b????;*.c??;*.c???;*.c????;*.d??;*.d???;*.d????;*.e??;*.e???;*.e????;*.f??;*.f???;*.f????;*.g??;*.g???;*.g????;*.h??;*.h???;*.h????;*.i??;*.i???;*.i????;*.j??;*.j???;*.j????;*.k??;*.k???;*.k????;*.l??;*.l???;*.l????;*.m??;*.m???;*.m????;*.n??;*.n???;*.n????;*.o??;*.o???;*.o????;*.p??;*.p???;*.p????;*.q??;*.q???;*.q????;*.r??;*.r???;*.r????;*.t??;*.t???;*.t????;*.u??;*.u???;*.u????;*.v??;*.v???;*.v????;*.w??;*.w???;*.w????;*.x??;*.x???;*.x????;*.y??;*.y???;*.y????;*.z??;*.z???;*.z????;*.0??;*.0???;*.0????;*.1??;*.1???;*.1????;*.2??;*.2???;*.2????;*.3??;*.3???;*.3????;*.4??;*.4???;*.4????;*.5??;*.5???;*.5????;*.6??;*.6???;*.6????;*.7??;*.7???;*.7????;*.8??;*.8???;*.8????;*.9??;*.9???;*.9????;
(I had to use various combinations of ? instead of a single * because the final extension could still be .svn)
Related
...yes I know this is an old tune, but I would like to make it specific to the newest tool, and also put in context and emphasize the issue. Doing this in hope that soon we will have a working solution.
Context
In many web projects there are zillions of library files like jquery, bootstrap etc. To make it worst, there are the .min. siblings, what are one liner, so editor killers. Usually we do not want to search within those files and it is a productivity killer, especially if one accidentally clicks on a found .min. file which freezes the editor when opens...
Question
Is there any way to define and exclude folders in a project or solution when using VS 2019 Find in Files?
If you press the button to the right of the "Look In" drop down:
you can select a set of folders to use. This set of folders can be saved for future use (ie. the lack of ability to include a parent folder and then exclude a child is not as bad as it could be).
Complex solutions usually contains several projects.
Currently I have more than 30 projects in a solution.
Some of the projects could contain many files inside (up to 1000 or more).
So when you open files from different projects all this stuff is expanded.
So if I want to find some file using solution explorer I need to scroll forever until it will be found.
Of course it is possible to navigate to it using Resharper's Ctrl+T but this is not related to those files you don't remember names but remember in which project and in which folder it is located.
I've tried to find some extension which could create tabs from projects but unfortunately unsuccessfully.
So is there any way to effectively navigate in such scenarios?
Some ideas:
Organize files into folders so that you don't have more than a few folders open when working on any given feature
Forget files; instead, navigate to class by name. Ctrl+, is the default shortcut.
Use F12 to go to definition; this also avoids having to find the file.
Search by keyword. Ctrl+Shift+F finds in all files. You just need to remember something from the file; it doesn't have to be the file name.
Enable "Track Active Item in Solution Explorer" in Options / Projects & Solutions / General. This keeps the file that is being edited selected in the solution explorer (but does lead to lots of folders expanding all the time).
Conversely, disable "Track Active Item", then you'll be in charge of what folders are expanded. Try both, see which one works best.
Use Solution Folders, which enable you to place several projects into a folder.
Is it possible to exclude certain files from search in Visual Studio.
For example jquery.js is almost always polluting my search results with half result coming from that file.
I know you can white-list specific types, but when I want to search in .js extension is there solution for that?
Vote here for feature: https://developercommunity.visualstudio.com/idea/405990/code-search-exclude-files-from-search.html?inRegister=true
Altough it does not solve your problem it may help out a bit
Ctrl + Shift + F should trigger the Find and Replace window.
From there, click Result Options and select "Display file names only".
It won't have all the info you need but might make it easier to recognize the files.
In Visual Studio 2019 they modernized the "find in files" feature, now you can exclude files, file extensions and directories using an exclamation mark before the items to be excluded in the "File types" textbox, like this:
*.*;!jquery.js
another example:
!*\bin\*;!*\obj\*;!*\.*;!*.xml
More info: https://devblogs.microsoft.com/visualstudio/modernizing-find-in-files/
In Visual Studio 2017 there is a workaround: you can right-click a search result and then click Delete. I use it to eliminate the big minified files from the Find Results window.
I've got the same problem with unwanted .js files polluting the search result. Especially the minified versions (e.g. jquery.min.js) are really annoying since they consist of only one (1) single very very long line. All of that line is displayed line-wrapped in search result. Not ideal!
Possible solutions:
Since .js files are (normally) just static content, you should be able to name them as you like. Rename it to jquery.min.js.nosearch and include the file with <script type="text/javascript" src="jquery.min.js.nosearch"></script> in HTML.
Get these files from an CDN and delete your local files.
Exclude these files from the VS project, provided that you can handle the inclusion of them in an other way when needed, e.g. when deploying (and provided that you scope your search to solution/project, not folder).
From this answer there was an UltraFind extension, which unfortunately doesn't exist for newer than 2010 (but see thread for hack to "update" it to 2012)
It's not particularly elegant - I'd be reluctant to call it a solution to the question - but if you can have Visual Studio Code running side-by-side with VS201x, its Find and Replace feature is pretty sophisticated. If you're using Git for source control, it will exclude any files or folders found in .gitignore from its search results - this is great when used in conjunction with tools like LibMan. Failing that, you can always manually add files / folders to its "files to exclude" option when searching.
Is there any way to prevent the contents of .svn subdirectories to show up in Visual Studio Find in Files results?
An alternative would be to make it ignore hidden subdirectories.
According to the documentation for "Find in Files":
The Find and Replace tool does not search directories with the Hidden or System attribute set.
However, this seems to be only partially true. For VS to ignore hidden/system directories, the "Don't show hidden files, folders, and drives" option in Explorer must be set.
If you're like me, that's one of the first things you do on a Windows computer - change that setting to "Show hidden files, etc..." (along with showing extensions - it baffles me that anyone thinks that not showing extensions is a good idea or is less confusing than showing them).
Having files in the .svn metadata show up in search results is one of the very irritating things about using SVN and/or search tools that don't let you easily exclude the directories. Unfortunately, VS's "Find in Files" seems to be one of those irritants unless you're OK with to hiding the directories system-wide along with all other hidden files and directories.
Personally, I can usually get by with 'mentally' filtering those directories from the search results. If it's a particularly bad set of results, and you really, really need the filter, you can flip the setting in Explorer, perform the search , and change the setting back without having to reboot or restart VS or anything. That's a small consolation, but I was half expecting to have to restart VS for the setting change to take effect.
Also, if what you're really searching is the Project or Solution rather than an arbitrary location on the file system, you can tell "Find in Files" to search files in the Project/Solution as hunter suggested. But I assume that's not what you're searching, or you probably wouldn't be having this problem.
I believe you can do the following:
In the Find in Files dialog, click the [...] button next to Look In:
dropdown
In the Choose Search Folders dialog choose the folders you normally wish to search from the Available Folders section. Be sure not to select the .svn folder (mine appears to be only in the root folder, thankfully not in each sub-folder)
Click the > button to add them to the Selected folders.
In the Folder set dialog, give this set of folders a name e.g.
(Trunk)ProjectDatabaseFiles
Click Apply button then OK button
You can now select that set of folders by name in the Look In dropdown of the Find In Files dialog in there-by skipping any .svn files for the search
More specifically my problem is if I include a pdf in my project and set its build action to content so it gets copied to the server when I publish, is there a way to exclude it from visual studios search and replace feature. Would a post build action be a solution to this? I just don't want anybody to do a global search and replace in my project and mess up the pdfs...
I know I just said a mouth full so let me know if you need clarification. Thanks!!!
If you look in the section headed "Find options" in the find dialog, there is an option titled "Look at these file types". If you qualify the type as *.cs, it will only look in files with that extension. You can also enter multiple file extensions. As long as you don't include pdf files in that filter, it will not apply to them. An alternative is to define a folder set to search in by clicking the ... next to the folder combo. Put your PDF files into a sub-directory of your project and exclude that folder from the folder set.
Additionally, as you have said, not including them in the project and using a post-build event to copy them to the output would also work.
I would qualify though that you are trying to solve a problem that shouldn't really be a problem. The onus is on the developer doing a find and replace to take care in doing so, and to not replace the contents of files they don't intend to change in the first place. Find an replace can be a dangerous tool.