开发者

Proper alternative for the unreliable Search and Replace of Visual Studio?

Today I was actually wondering why I've stuck with it for so many years without actively complaining about it. Doing a "search & replace in all files and folders of a solution" is something I quite regularly need to do, esp. when refactoring tools fail me. Unfortunately, "all folders and files" means "some projects and some other files". Notably, unconnected files in solution folders, complete web sites and csproj/vbproj/sln files are skipped.

Also, just searching often reveals more hits than replacement rep开发者_JS百科laces (for instance, a csproj is only replaced when its project is unloaded).

Ok, enough complaining: anybody aware of a good plugin or a nice valuable trick that can do a real search and replace through all files and folders of a solution? Something I can rely on?

(edit)

PS: after some more thought: having your system under Subversion or other source control system will make a full search only really valuable when the folder-list could contain a filter of exclusions, i.e., exclude all .svn files and dirs. Unfortunately, as far as I know, that's not possible with the supplied solution.


While it's not a plugin for Visual Studio Notepad++'s find (and replace) in files functionality seems to be solid.

You even get syntax highlighting of your code - though not for aspx files by default. However, this post tells you how to get it working.

UPDATE

You can get a more comprehensive search and replace from within Visual Studio.

Ctrl+Shift+H to go the the dialog up.

Then select the ... button next to the "Look in" drop down to get the "Choose Search Folders" dialog.

Pick your folder and then do your search and replace (or just search even).


I have the same issues with "Entire Solution". In fact it is not effectively "entire" and that's the point. I shouldn't need to learn how to use the tool. Is there a tool for me or am I for the tool? It is so simple - "entire" means "entire" for me but not for the feature developers.

For now I don't use "Entire Solution" but I replace it with a path every time. It's not perfect because it may search other files in the directory that are outside the solution but it's more reliable.


You could use the VS Command Shell and let Windows do the walking. Even if you don't use it for S&R, it's nice to have.


I agree that it's not the best search tool in the world, but I've never had any of the problems you describe.

You imply that it is not possible to filter the files searched in Visual Studio, and that files on disk that are not referenced in your solution are not searched. Well, that's because you've asked Visual Studio to do that - I think you need to learn how to use the tool better, because it handles these situations perfectly well.

You can set the search to work on a solution, on specific projects, the current project, open documents only, the current document, or search any folder hierarchy on your drive with a list of filename filters to choose precisely what is scanned. These settings can be saved and then used whenever you need them by just choosing the pre-set in a combobox. The user interface for setting this up is pretty awful, but once it's set up it works well. For example, I often use an "entire codebase" to search my drive rather than "Entire Solution" which only searches the files in my solution. Or "All XML files". Or "All Source files but no headers". Etc.

If you have problems with scanning open projects, then don't - just run another instance of VS with no solution loaded in it. The idea of trying to use one instance of VS to handle everything (with all the window layout reconfiguring that is necessary as you swap between tasks) quite frankly baffles me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜