Find all occurences in this file.
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Find all occurences in this file.
As I've posted in Enhancements, I've used an editor where every line
with an occurence of the selected text in the current document
can be found and displayed in a floating command results window (with
line numbers and hotlinks back to the relevant places). This
is very useful for checking all assignments to a particular signal
(check it's initialised properly, not assigned in any strange places etc).
As an interim it would be handy to do the same with the current command
results window. I've tried this before with no success, can anyone help?
As above, all I want to do is have a copy of every line with the selected
text copied to the command result window with hot links back to the
sources.
Can this be done?
Thanks for any help,
Nial.
with an occurence of the selected text in the current document
can be found and displayed in a floating command results window (with
line numbers and hotlinks back to the relevant places). This
is very useful for checking all assignments to a particular signal
(check it's initialised properly, not assigned in any strange places etc).
As an interim it would be handy to do the same with the current command
results window. I've tried this before with no success, can anyone help?
As above, all I want to do is have a copy of every line with the selected
text copied to the command result window with hot links back to the
sources.
Can this be done?
Thanks for any help,
Nial.
> You may get some mileage out of using Mark All, on the Find dialog
> box, so you can then use F2 to visit each matching line, or any of the
> commands on the Edit menu that can be applied to bookmarked lines.
I don't think that'll do it Keith, I'm hoping to extract line numbers
etc.
If you could pass what's on the clipboard (another enhancement
suggestion) to an external comand I could write a Perl script which
would extract the relevent line numbers with the lines, these would
then end up in the command results, providing the hot links.
Oh well, I'll have to be patient and wait for the next release (hopefully).
Nial.
> box, so you can then use F2 to visit each matching line, or any of the
> commands on the Edit menu that can be applied to bookmarked lines.
I don't think that'll do it Keith, I'm hoping to extract line numbers
etc.
If you could pass what's on the clipboard (another enhancement
suggestion) to an external comand I could write a Perl script which
would extract the relevent line numbers with the lines, these would
then end up in the command results, providing the hot links.
Oh well, I'll have to be patient and wait for the next release (hopefully).
Nial.
Actually, to automatically search the current directory (and no subdirectories), just press Alt+U when in the Find In Files dialog box. This activates the "Set to Defaults" button. If you do want to search sub-directories, then Alt+S right after pressing Alt+U. For some reason, this checkbox is unchecked by default.
This should be closer to what you want. I use it all the time.
This should be closer to what you want. I use it all the time.
-
- Posts: 26
- Joined: Tue Mar 04, 2003 7:33 am
If you have a grep than you can set up a tool which uses this as a command:
The command would be cmd.exe
The parameters are:
grep -n "$SelWord" $File
The directory is not important.
The regexp to jump to would be:
^\([[:digit:]]+\):
Just set the "line"-listbox to "1".
Then you can select the word you are looking for and invoke the tool. The results go to the output window and you can jump to any occurence.
I use this all the time when ctags is not helping.
HTH
Jens
The command would be cmd.exe
The parameters are:
grep -n "$SelWord" $File
The directory is not important.
The regexp to jump to would be:
^\([[:digit:]]+\):
Just set the "line"-listbox to "1".
Then you can select the word you are looking for and invoke the tool. The results go to the output window and you can jump to any occurence.
I use this all the time when ctags is not helping.
HTH
Jens
Jens, I like your idea very much, can you please recommend where to find a grep for Windows?
In the meantime, Nial, you could "write" a textpad macro. The macro would run after you have tagged the lines you're interested in, which could be achieved manually or by using the Mark All button on the [Find] dialogue. Here's pretty much what the macro should do:
Edit / Copy Other / Filename
<RegExp Find:>^
<ReplaceWith:> <paste contents of clipboard>(\i):<space>
Edit / Copy Other / Bookmarked Lines
<Undo> -- This loses the filename and line numbers, but preserves the clipboard.
File / New
<Paste>
File / Save As / _index.ndx
<Execute Tool:> <the one that types the current file> -- consult TextPad help for "stdout" if you don't already have such a tool.
You'll also want to delete the _index.ndx file etc, but the typed results are now hypelinks to each tagged line in your original document. Hope this helps.
In the meantime, Nial, you could "write" a textpad macro. The macro would run after you have tagged the lines you're interested in, which could be achieved manually or by using the Mark All button on the [Find] dialogue. Here's pretty much what the macro should do:
Edit / Copy Other / Filename
<RegExp Find:>^
<ReplaceWith:> <paste contents of clipboard>(\i):<space>
Edit / Copy Other / Bookmarked Lines
<Undo> -- This loses the filename and line numbers, but preserves the clipboard.
File / New
<Paste>
File / Save As / _index.ndx
<Execute Tool:> <the one that types the current file> -- consult TextPad help for "stdout" if you don't already have such a tool.
You'll also want to delete the _index.ndx file etc, but the typed results are now hypelinks to each tagged line in your original document. Hope this helps.
Thanks Guys,
I'm busy on something at the minute but will try these suggestions
later today if I can.
$Selword is exactly what I'm looking for, I suppose I should have
RTFM as they say
I can write a Perl macro to extract the relevant lines easily enough,
and I might try a Windows grep to get a speed comparison (a google
search gives pleanty of results for 'Windows grep").
All we need now is a floating Command or Search Resilts window and
I'll be happy
Thanks again, these forums (fora ?) really are invaluable.
Nial.
I'm busy on something at the minute but will try these suggestions
later today if I can.
$Selword is exactly what I'm looking for, I suppose I should have
RTFM as they say
I can write a Perl macro to extract the relevant lines easily enough,
and I might try a Windows grep to get a speed comparison (a google
search gives pleanty of results for 'Windows grep").
All we need now is a floating Command or Search Resilts window and
I'll be happy
Thanks again, these forums (fora ?) really are invaluable.
Nial.
Jens
Sorry, a bit off the subject, but what are ctags please? I've seen references to them but I don't understand them.
Ed
ezdzozrzczhard@yazhoo.com (remove z's)
Sorry, a bit off the subject, but what are ctags please? I've seen references to them but I don't understand them.
Ed
ezdzozrzczhard@yazhoo.com (remove z's)
-
- Posts: 26
- Joined: Tue Mar 04, 2003 7:33 am
Hi Nial: When you can write perl-scripts you have my respect and you should never have any problem whatsoever :-)
A floating output window! Nice idea.
Ed: Look under http://ctags.sourceforge.net/
Kind regards
Jens
A floating output window! Nice idea.
Ed: Look under http://ctags.sourceforge.net/
Kind regards
Jens
> Hi Nial: When you can write perl-scripts you have my respect and you
> should never have any problem whatsoever
I only wish that was true
Perl's not difficult to pick up. Some people seem to delight in writing
as obtuse Perl code as possible, but it's not big and it's not clever
Although when you get proficient you can take shortcuts, to start
you can do things in steps and keep things simple. You can even
comment it!
See the 'Perl' and 'Links' pages on my web-site below for more
details.
> A floating output window! Nice idea.
This is _very_ useful. It allows you to navigate your command/search
results, finding the relevant bits in the source file without having to
constantly context switch between the two windows. It's part of
my enhancement request 'usage in this file....', perhaps I should
add it as a seperate request?
Anyway, back to 'find all occurences in this file'.
I found a few grep routines that are windows based before I tried..
http://www.interlog.com/~tcharron/grep.html
...a good fast command line version.
As Jens suggested above...
Command = cmd.exe (win2K)
Parameters = grep -n "$Selword" $File
Regexp = ^\([0-9]+\):
(This seems to work better than '^\([[:digit:]]+\):' when there's
no space after the 'line_number:' for some reason).
This is fast and working really well, I can see if being invaluable. As well as
being able to trace signals through a design I can quickly extract
signals / pins from lists. As an example in a list of 480 pins I wanted to
check all those with a 'RESERVED' assignment. This feature quickly
gives me a printable list I can work from.
Thanks guys.
Nial
--
Nial Stewart Developments Ltd
www.nialstewartdevelopments.co.uk
> should never have any problem whatsoever
I only wish that was true
Perl's not difficult to pick up. Some people seem to delight in writing
as obtuse Perl code as possible, but it's not big and it's not clever
Although when you get proficient you can take shortcuts, to start
you can do things in steps and keep things simple. You can even
comment it!
See the 'Perl' and 'Links' pages on my web-site below for more
details.
> A floating output window! Nice idea.
This is _very_ useful. It allows you to navigate your command/search
results, finding the relevant bits in the source file without having to
constantly context switch between the two windows. It's part of
my enhancement request 'usage in this file....', perhaps I should
add it as a seperate request?
Anyway, back to 'find all occurences in this file'.
I found a few grep routines that are windows based before I tried..
http://www.interlog.com/~tcharron/grep.html
...a good fast command line version.
As Jens suggested above...
Command = cmd.exe (win2K)
Parameters = grep -n "$Selword" $File
Regexp = ^\([0-9]+\):
(This seems to work better than '^\([[:digit:]]+\):' when there's
no space after the 'line_number:' for some reason).
This is fast and working really well, I can see if being invaluable. As well as
being able to trace signals through a design I can quickly extract
signals / pins from lists. As an example in a list of 480 pins I wanted to
check all those with a 'RESERVED' assignment. This feature quickly
gives me a printable list I can work from.
Thanks guys.
Nial
--
Nial Stewart Developments Ltd
www.nialstewartdevelopments.co.uk
Just to update....
I've just realised that my last configuration was
case sensitive.
If you want the search to be case in-sensitive use
Parameters = grep -n -i "$Selword" $File
The -i switch makes grep ignore cases.
Nial.
case sensitive.
If you want the search to be case in-sensitive use
Parameters = grep -n -i "$Selword" $File
The -i switch makes grep ignore cases.
Nial.
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
I might be late to the party but Windows offers the find command if you don't want to snag grep (although I highly recommend either grabbing cygwin or mingw to get unix tools for windows {and I further recommend leafing through the man [manual] pages on the tools to see what you've been missing})
Thus, for case insensitive searches
Parameters = find /n /i "$Selword" $File
and case sensitive searches
Parameters = find /n "$Selword" $File
In the immortal words of DK, beware of bugs in the aforementioned code, I have not tested it, only eyeballed it as correct.
Thus, for case insensitive searches
Parameters = find /n /i "$Selword" $File
and case sensitive searches
Parameters = find /n "$Selword" $File
Code: Select all
c:\>find /?
Searches for a text string in a file or files.
FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]]
/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.
If a path is not specified, FIND searches the text typed at the prompt
or piped from another command.
Regarding the use of Find in Files (ctrl +F5) to locate all occurrences of specific text in a document:
If you specify your filename (e.g: myfile.c) in the "In Files" text box then TextPad will search only that file. The results will be in TextPad's Search Results window. It is not necessary to search all files in a directory.
Unfortunately the Search Results window is not floatable but it can be tiled with the document you just searched and by selecting a match in the Results window, TextPad will take you to that line in the document.
Still a bit kludgy, but it is fairly simple to do without developing macros, etc.
I too would prefer that TextPad have a 'All Matching Lines' option on the Find (F5) dialog.
If you specify your filename (e.g: myfile.c) in the "In Files" text box then TextPad will search only that file. The results will be in TextPad's Search Results window. It is not necessary to search all files in a directory.
Unfortunately the Search Results window is not floatable but it can be tiled with the document you just searched and by selecting a match in the Results window, TextPad will take you to that line in the document.
Still a bit kludgy, but it is fairly simple to do without developing macros, etc.
I too would prefer that TextPad have a 'All Matching Lines' option on the Find (F5) dialog.
-
- Posts: 9
- Joined: Tue Dec 28, 2004 10:55 pm
- Location: Colorado
- Contact:
Grep for Windows
GNU utilities for Win32, at http://unxutils.sourceforge.net/Jens, I like your idea very much, can you please recommend where to find a grep for Windows?
HTH.
- SamR