PTVS
PTVS copied to clipboard
Search and replace goes into all modules in site-packages
Visual Studio 2022
When using search and replace in a project with a python virtual environment it goes into the installed modules.
Steps to Reproduce
- Create a virtual environment
- Install some modules
- Make a folder in site-packages for your own package you are working on.
- Use search and replace and it will go into every package under site-packages (using replace all is then a disaster)
Expected behavior I expect search and replace to work only on source code that is actually part of my project
disclaimer I don't recall having this issue in 2017 or 2019 but not sure I ever made my own module in site-packages in a virtual environment as part of my project.
Thanks
Hi there, the File types textbox can exclude files. Any path or file type prefixed with the “!” character will be excluded from the search. For instance, you can add !*\site_package* to the file types list to exclude any files in a site_package folder. Could you give it a try and let us know if that works? Thanks!
This project is a python package so to test while coding it I need it in the site-packages of the virtual environment. Using a filter means I would have to exclude every other package in installed. If I filter site-packages it would ignore my code then.
Is there some other setting so it only searches files that are actually part of your project ? This should be doable since all files part of the project are listed in the VS project file.
Thanks
Hi @therealzoomgod, unfortunately, I don’t think we have that capability. That would be a new feature. But thanks for bringing this up! 😊 The walkaround for now is probably do the search and replace twice, one in the folder you made in the site-package, and do another search to exclude the site package folder.