 |
|
|
 |
|
|
 |
|
 |
I'm using it espacially with VS2010 and it's doing nicely so far
|
|
|
|
 |
|
 |
Multi-line doesn't work on regular character classes like [.]* or [.\r\n]*, it only works with a negated char class like [^terminatorcharshere]*. This makes it hard to match against a non-single-character delimiter, like 'grab everything until the word GO'. I can do that with this:
[^$]*?$?(go)
but that is ugly and hard to read.
If I do a 'replace all', then try to do another find, it operates on an old copy of the text. So a second replace all can revert a first replace all. Saving and closing and reloading the file works around the problem, but it's a scary bug to run into.
|
|
|
|
 |
|
 |
I can confirm some weirdness when using '\r' and '\n' in an expression, but I don't think it has anything to do with the multi-line option. All the multi-line option does is change the meaning of '^' and '$', which you aren't using in your expressions. Your example character classes and your comment about matching "against a non-single-character delimiter" suggest a misunderstanding about the way character classes work. Characters within character classes are interpreted literally; meta-characters, like '.' do not have the same meaning as they do outside of a character class. As for your comment about "non-single-character delimiters", that is all a character class can do; match a single character. Your example of "grab everything until the word 'go'" can be done easily without character classes with this expression (using the single-line option, which lets '.' match newlines):
.*?(go)
If you don't want to include the word "go" in the match, use a look-ahead assertion:
((?!go).)*
All that being said, I will look into the '\r' and '\n' problem as well as the 'replace all' issue. I'm not sure when I will have time to do it, but I will post another comment here when I submit an update, so you will know.
Thanks for pointing out the bugs.
Jeff
|
|
|
|
 |
|
 |
Alo
Thx for this nice addin. But I have problem with \r and \n. Do you have a status on this problem?
|
|
|
|
 |
|
 |
Back when this first came up, I spent an hour trying to track down the problem and I did make some progress, but I haven't had a chance to look at it again since then. Other projects have a higher priority now, so I'm still not sure when I will be able to put this one to bed. Thanks for the reminder, at least. I will get to it eventually.
Jeff
|
|
|
|
 |
|
 |
Nice plugin!
It's a big mystery to me why VS uses a different flavour of Regex then .NET. Just a few very minor comments:
1) The sub-menuitems (lookaheads) don't fire.
2) It would be nice to resize the dialog.
3) It would be nice to have the menus as a context menu (for faster entry).
Anyway, thanks & you have another deserved 5!
|
|
|
|
 |
|
 |
So... love this add-in and it will be some time before I migrate to 2010, but... any plans for this in 2010? I understand add-ins are a new animal in 2010.
|
|
|
|
 |
|
 |
I just finished installing VS2010 this afternoon. I don't know when I will get a chance, but I will do my best to make it work.
|
|
|
|
 |
|
 |
Excellent. Looking forward. Thank you for your work.
|
|
|
|
 |
|
 |
Good news. The Addin seems to work (almost) as-is with VS2010. You just need to put the binaries in the VS2010 Addins directory. You will find it here (if you are using XP): C:\Documents and Settings\<username>\My Documents\Visual Studio 2010\Addins Copy RegexFindAndReplace.dll and RegexFindAndReplace.Addin to the above directory, and then open RegexFindAndReplace.Addin in a text editor and change the version number to 10.0: <Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility"> <HostApplication> <Name>Microsoft Visual Studio</Name> <Version>10.0</Version> ... That seemed to do the trick for me. Jeff
|
|
|
|
 |
|
 |
Sweet. Just got to get 2010 installed now Thanks for the replies.
|
|
|
|
 |
|
 |
Rats - just am getting around to trying it and I am getting "The Add-in... failed to load or caused an exception.... Error number: 80131515". I have VS2010 ultimate (4.0.30319). The google results I'm seeing for that refer to loading an addin from a network share, which I'm not.
I re-downloaded the addin and extracted directly to Visual Studio 2010\Addins and changed the version in the .Addin file, same error.
I am running Windows 7 64bit as well... I'll try recompiling the source and give it another go.
... When I looked at the properties for the dll, I saw the verbage that "This file came from another computer and might be blocked...". I clicked Unblock and viola, it's working now. Thank you. Hopefully this may help others.
modified on Tuesday, November 9, 2010 7:52 PM
|
|
|
|
 |
|
 |
I'm glad you figured it out. I've been using the Addin with VS2010 for quite a while, so when I first saw your message, I was pretty confused. Thanks for posting your solution.
|
|
|
|
 |
|
 |
Hi
I found couple of differences between the output of Replace & Replace All. (btw, I'm using Regex Relace In Files option)
1. Even if I use the same pattern for Replace with, the formatting is different in these 2 cases. This is because when I click on Replace it starts replacing each occurance one by one. In this case VS comes into play and formats the replacement string in its own way. So I removed all the white space (except \n) that I had put into Replace With string. But when I clicked on Replace All, it didn't do any formatting at all. This is because I had removed all the white space and somehow VS didn't play its role in this case. Can this be handled in a way that no matter which button I'm clicking, the final output will be same [as long as I'm not changing anything in the Find what & Replace with]
2. Is there a difference in the way the file is written after Replace and Replace All? When I clicked on Replace All, ® (R) character changed to �.
In both the cases I had selected "Keep modified files open after Replace All". So I assume: in both the cases its VS who is going to write / change the physical file. Is that right?
Thanks & Regards,
- Vivek Athalye
|
|
|
|
 |
|
 |
For your first issue, I'm afraid that I can't do much to help you. With a Replace All, if the file isn't open, the replacement is performed on the text of the file, and the file is rewritten; anything Visual Studio is doing to format the text when the file is open is not going to happen. You can always modify your regular expression to do what Visual Studio is doing for you.
I couldn't reproduce the second issue with the ® character changed to �, but I did find what might be causing it. I now store the encoding of the file before I make any changes to it, and then use that same encoding when writing out the file again.
I just submitted an update that I believe addresses all of your concerns. Please let me know when you have had a chance to try it out if anything remains broken. It might take a couple of days for Code Project to post my updates.
Jeff
|
|
|
|
 |
|
 |
Hi Jeff,
I can understand the problem related VS formatting. By any chance, is there any way to disable VS auto formatting temporarily, just when we are replacing the text. This way the formatting given in the regexp will come into picture. And this formatting will (hopefully) be the same for all the files... no matter if they are opened in VS or not. What say, will this work?
I'll take a look at the updated code in couple of days. Thanks a lot for your support
Thanks & Regards,
- Vivek Athalye
|
|
|
|
 |
|
 |
I haven't been able to find a way to disable it, but the formatting Visual Studio does automatically does get added to the undo/redo stacks, so it might be possible to call this.applicationObject.ActiveDocument.Undo() after the replacement has been made, and after it has been confirmed that the automatic formatting has happened too.
|
|
|
|
 |
|
 |
Hello,
This is a really good plugin , and I must say it will surely help me a lot. But as of now I'm not able to find some specific text in .cs (code behind) files.
After debugging the code I realized that its not calling FindAllInFile() method for any of the code behind files. It invokes this method for all ASCX files but not for the related cs files. Am I missing some setting that needs to be done?
As of now I've modified the code in ProcessAllInProject() and ProcessAllInProjectDirectory() method so that it recursively invokes ProcessAllInProjectDirectory() for each ProjectItem.ProjectItems colleaction.
This way at least the code behind files are getting checked.
I'm still having some more problems (not getting all the expected results), but I guess they are related to the regular expressions that I'm using. Anyway I'll continue to explore it further.
Please let me know if I'm missing something for getting the code behind files parsed.
Thanks & Regards,
- Vivek
|
|
|
|
 |
|
 |
Maybe I'm misunderstanding you, but ProcessAllInProject and ProcessAllInProjectDirectory already call ProcessAllInProjectDirectory recursively for each ProjectItem.
I'm not a web developer, so I don't deal with ASCX and code behind files. It is possible that there is something unique about the way those kinds of projects are set up. I will try to look at this when I get a chance.
Jeff
|
|
|
|
 |
|
 |
Yes you are right, those methods have recursive calls, but inside some condition, because of which I was not getting expected result.
Actually I've not worked on windows forms any time, but to see the difference I created a windows forms application. I could see the structure as follows:
Project
--Form1.cs
----Form1.designer.cs
In ASP.Net project the structure is:
Project
--Default.aspx
----Default.aspx.cs
----Default.aspx.designer.cs
So, as you see, the code behind file (Default.aspx.cs) is not a direct child of project and hence its not part of the Project.ProjectItems collection. Instead its a child node of a vsProjectItemKindPhysicalFile.
I hope this will give you the idea of the problem that I was talking about. If you need any more clarification please let me know.
Btw, I'm trying to resolve this problem (changing all the places where the file list is getting generated) but I might miss out some places. Will it be possible for you to fix it?
Another issue that I'm facing is, if I click on "Skip File" its "opening" all the files in current project.
Thanks & Regards,
- Vivek Athalye
|
|
|
|
 |
|
 |
I would be happy to fix it. Would you mind telling me all the places you have worked on, so I can be sure I don't miss anything? It has been so long since I have made any changes to this project, there is a good chance I won't remember how everything works..
|
|
|
|
 |
|
 |
Hi Jeff,
I tried the latest code. The CollapsibleGroupBox is working fine, but I still faced the old problems that I had mentioned.
1. code behind files not processed
Can you please check the code that I had sent you. Search in the project for "Vivek" to find out my code changes. [or may be you can use some file/folder comparison tool, that will be much easier]
2. ® character changed to �).
I select "Keep modified files open after Replace All" option, and I click on Replace All. After that when I try to save the file, VS shows me following message:
---
Some Unicode characters in this file could not be saved in the current codepage. Do you want to resave this file as Unicode in order to maintain your data?
---
I select the option to save as Unicode, and thats when I lose ®.
I also noticed that file size becomes almost double the original file size.
I hope this info helps.
Thanks & Regards,
- Vivek Athalye
|
|
|
|
 |
|
 |
Is there any chance you could email me a sample project that has these problems? I created a test web project with code-behind files, and the problem went away with my recent changes.
For the second issue, could it have something to do with region settings? I couldn't duplicate it at all. I follow the same steps you describe, and when I save the file, it just saves, with the ® character intact.
Jeff
|
|
|
|
 |