Excluding specific files from Visual Studio search

前端 未结 6 943
一整个雨季
一整个雨季 2021-02-01 00:15

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 tha

相关标签:
6条回答
  • 2021-02-01 00:41

    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.

    0 讨论(0)
  • 2021-02-01 00:45

    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/

    0 讨论(0)
  • 2021-02-01 00:48

    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).

    0 讨论(0)
  • 2021-02-01 00:50

    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)

    0 讨论(0)
  • 2021-02-01 00:55

    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.

    0 讨论(0)
  • 2021-02-01 00:59

    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.

    0 讨论(0)
提交回复
热议问题