Search only text files in VS2012 "Find in Files" - visual-studio

In the Find in Files dialog (Ctrl-Shift-F), is there any way to search only text files in Visual Studio 2012?
I am working on a website that has 100,000's of images.
When I search for a string apparently it searches through all the .jpg and other non-text files (unless you specify the file extension(s) which sometimes you can't do because you just can't tell where the string might appear)

The find-dialog gives you an option to restrict the search:

Find and Replace window has Look at these file types drop down control. You can write here file extension (*.txt, *.cs etc.) what you want to search in it.

Just add the file types filter should include .txt, .aspx, etc.

Related

Excluding specific files from Visual Studio search

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.

Can I filter find/replace to only search header files in Visual Studio?

I am using Find and Replace in Visual Studio 2010. Currently, I can filter the search to only look in:
the current document
the selection
all open documents
the current project
the entire solution
the current block
These are some great filters, but I would like to search only in header files. Is there a way to search only in header files?
I am currently using grepWin to search and accomplish this externally to Visual Studio. Is there a way to search in Visual Studio. Plugins are acceptable answers.
Rather than use filters, use file types instead (maybe combined with filters). Open the Find Options section in the "Find In Files" perspective of the Find and Replace dialog.
For example, you can search all *.h files within the solution. Or all *.h files found under folders c:\my_projects;c:\work_projects (the filter drop-down allows multiple folders).

Visual Studio - Exclude moles files from search

I know Visual Studio allows you to specify what kinds of files you want to search in the find and replace dialog, which works well in general. Generated moles files, however, have a path ending in "m.g.cs". When searching for .cs files, these are also searched, which produces a ton of noise in the find results. Is there a way to specify that files matching "*m.g.cs" should be ignored in the find and replace?
Did you try adding a new item (folder set) to the Look in drop-down list?
Here's how it's done:

Visual Studio find - filter by file type?

Is there any way to use Visual Studio's Find and Replace to search only through files of a specified type or types?
If I'm searching through my web project for a particular string, it winds up looking through all my javascript, css and html files when I know all that I'm interested in is results that are in .cs files, for example.
I find myself using Notepad++ which does have the ability to limit its "Find In Files" search to only the file types I specify within the directory I specify, but would love an integrated solution.
You can choose file types from default or type your own. Regular expressions available for complex search.
In the Find Options, you can specify the settings under "Look at these file types:"

How do you exclude .svn directories from search in Visual Studio?

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)

Resources