Is it possible to include comments in a search? Or maybe even exclude code and search for comments only?
Like for example
int a = 1;
//int b = 2;
If I search for int I will only find the int which is not commented. I want to find the commented one.
edit
another thing I just noticed. When I search for things in xaml I cannot find them either. example:
<TextBlock x:Name="veryImportant"/>
cannot be found by searching for for example TextBlock or Name or veryImportant
Could it be possible to find it somehow?
Visual Studio does allow for string searching in comments, although, in your example, it is possible that you have it set to "Match whole word" -- can you confirm that this is not the case?
Using CTRL + f , you can do a simple text find which will include comments.
Related
I have about a thousand images on my site, and I need to add a script tag <%=Settings.MyDomain%> to all of them. It will be a very long process unless I could find some way to add the tag to all of the images that need it. Any ideas?
in visual studio, Ctrl + F, and use find and replace
You can use search and replace, but you probably won't get very far, since the image tags are not all the same. In this case you can use the Visual Studio option of Regex replace. There you can use regular expressions to replace your text, which allows you to not look for exact matches, for matches to a pattern.
How the Regex will look of course depends on how your search/replace texts look, but for general information you can check the respective MSDN page.
i want to store file:// as constant string to check is a particular String is URL.
public readonly String[] URLHEAD = { "http://", "https://","file://","\\\\" };
but but am not able to do it.
It's just the coloring indicating that it's a clickable link, exactly as if you start typing www after http://.
I wonder what made you think that you were unable to do something. You could compile and run your code anyway!
I highly suggest you try to pay more attention, as this "issue" was NOT really worth a question here.
Your code will work even if the color is blue. It is just an IDE setting as #Backs mentioned. But if you are really concerned with how it is marked up in your IDE then you can turn off the setting.
I'm assuming you are using Visual Studio.
Go to Tools\Options\Text Editor\C#\General\Enable single click URL navigation
I have a text file that I need to search and then print to screen certain phrases from it.
I can bring the text file into a string and find the index of thefirst part of the phrase like so;
int first = source.IndexOf(start-keyword);
Where source is the text file string and start-of-phrase is the first keyword I'm looking for.
However when I try to get the index of the end keyword I get stuck as sometimes the end keyword comes before the first keyword.
So I added the following bit to my code so it looks like:
int first = source.IndexOf(start-keyword);
string source2 = source.Substring(first, source.Length - first);
int last = source2.IndexOf(end-keyword) + end-keyword.Length;
phrases.Add(source.Substring(first, last));
Then the last line adds it to a list called phrases.
However I can't seem to find a satisfactory way to loop this as I start getting errors such as Out of range or not extracting the full phrase?
Thanks
You may want to look at using String.IndexOf Method(String, Int32) where you can specify the starting index value of the end of first start occurrence.
int last = source.IndexOf(end-keyword, first + start-keyword.Length )
+ end-keyword.Length;
This sounds like an ideal candidate for Regular Expressions.
Something like
"(\b[Pp]rogram\b)(.*)(\b[Vv]cvarsall\b)"
Should match
"Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall"
in
"something Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall something"
I am wondering say I have this string "Hi my name is chobo2" and I want to find all the files that have this string. Normally I would do ctrl + f in VS 2010 and do a find.
How do I find this string if it is in a resource file? Right now I have a string in a solution that has many projects. I know the project has at least one resource file but I cannot find the string I am looking for. I might have missed it as the file seems to have many string in it.
Is there any easy way to locate this string value in the resource file? This way I can find the "resource name" and thus find where the string is used in the project.
Edit
Just a side note
I opened up the resource file and tried to do a ctrl + f on it(search by current document) but it only searches on the "name" column not the "value" column
I think this will explain all you need to find the string. ****Cheers**** to vs2010
In resharper it is very easy -> find usages (or something similar)
But you can use Ctrl + Shift + F (select entire solution) in file type section type *.* or *.resx and click find (on panel below all occurrence should appear) double click should drive you directly to resx file (Xml)
Press Ctrl+Shift+F and select Entire solution. Then use F8 for navigation on found items. In addition, for finding related resource files, goto Tools->Option->Project and Solution and check Track Active Item to true.
I'm new to visual studio, so perhaps this is something easy... but I've had no luck finding how to solve this formatting issue.
I would like for VS to auto format this
int x =
5;
like this
int x = 5;
When I type this in and select 'Format Document' nothing changes.
It will also not remove unnecessary newlines such as
MyClass someClass =
new MyClass();
Any help for this would be great!
Visual studio can't fix that. You can do it with the Replace All dialog + regex if you are careful.
jgauffin is right. However you can format other items to speed up the process.
Tip for key combinations for general reformatting
Tip for using a macro to modify all files in your solution