Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29236 Discussions

how to search entire solution ignoring comments

Brian_Murphy
New Contributor II
1,577 Views

When using shift-control-f to search an entire solution, is it possible to ignore comments?

Also, where is shift-control-f located on the pull down menu of Visual Studio 2012?

Thanks,

Brian

Brevard, NC

0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,577 Views

Edit > Find and Replace > Find in Files is the menu item. I am not sure if it's possible to exclude comments, but you can search for references or definitions of identifiers if the advanced text editor features are enabled.

0 Kudos
Brian_Murphy
New Contributor II
1,577 Views

Thanks for the reply, Steve.

My VS 2012 doesn't have a Find and Replace item anywhere I could find on the Edit menu.  It has Find Symbol (Alt-F12), Quick Find (Ctrl+F) and Quick Replace (Ctrl+H).

How do I know whether or not I have "advanced text editor features" enabled?  I tried the Alt-F12 command, but trying this with a known variable name didn't seem to do anything.

Thanks,

Brian

0 Kudos
Steven_L_Intel1
Employee
1,577 Views

I see Edit > Find and Replace in my VS2012. This is a standard VS feature.

The advanced features need to be enabled under Tools > Options > Text Editor > Fortran > Advanced. Set all values to True except for "Disable Database".

0 Kudos
Brian_Murphy
New Contributor II
1,577 Views

My VS 2012 is version 11.0.50527.1 RTMREL

I sure can't find Find and Replace, but since shift-ctrl-F works, that's not a problem.

Thanks for the tip about turning on the Advanced editor features.  That looks like it will be very helpful to me.  However, the option for Highlight Matching Tokens doesn't seem to do what it says it's supposed to do.  Bummer.

Anyhow, the main thing I was after was to do a find that skips comments. It sure would be a great feature to add.  The editor already does color highlighting for commented text, so it already knows what is or isn't a comment.

Brian

0 Kudos
Steven_L_Intel1
Employee
1,577 Views

The problem is that MS doesn't give us hooks into Find and Replace. Maybe someone can come up with a Regular Expression that does what you want - I am not enough of a regexp expert to be able to do this.

Might it be that VS12 isn't showing you the full menus? I know that some MS tools did that for a while, trying to be "helpful".

0 Kudos
NotThatItMatters
Beginner
1,577 Views

I have always used the following construct to find things that are not commented:

Wildcard search expression = ^[^C!][^!]+{expression}

I use this a lot looking for WRITE statements which are often debugging statements.

0 Kudos
Brian_Murphy
New Contributor II
1,577 Views

Thanks for the regular expression suggestion.  I gave it a try, but it doesn't quite do what I'm looking for.  I actually can't tell exactly what it is doing, but it's not finding the lines I want.

For example, to find all lines containing a variable named EIVEC I used  ^[^C!][^!]EIVEC     but this only returned a small subset of the correct group of lines.

Brian

0 Kudos
NotThatItMatters
Beginner
1,577 Views

Yes, I have some trouble with this some of the time.  If you can be assured that the commented "EIVEC" lines start with a comment statement, you could use

^[^C!].+EIVEC

and ask it to search for whole words with regular expressions.  This works for me because I uniformly comment my "WRITE" lines at the beginning of the line.  Unfortunately I am guessing this is not the case with yours.

My only other suggestion is a better editor.  My personal choice is SlickEdit.

0 Kudos
Reply