You are here: PSPad forum > English discussion forum > Multi-Line Search Add-On

Multi-Line Search Add-On

Goto Page: 1 2 3 4 5 6 7 8 9 10 11 ...LastNext

#1 Multi-Line Search Add-On

Posted by: phdesigner | Date: 2006-10-12 07:14 | IP: IP Logged

phReplace - multiline search and replace for PSPad

.

Hey all you PSPad lovers out there.

I got tired of having to use another program
to do multi-line search and replace so I created a solution.

I'm looking for people to test this PSPad add-on, it's kind of beta version
cause I only finished it today so it's probably still got a few bugs.

- - -

Description:

phReplace is a multiline search and replace application for PSPad,
boasting the following features:

* Multiline Search and Replace text areas
* Search / Replace / Replace All commands
* Search scopes include the active document, all open documents or selected
text only
* Reverse search facility
* Search for Whole Words Only
* Perform a Case Sensitive Search

This add-on was born out of my frustration for not being able to perform a
search or replace on multiple lines without having to resort to regular
expressions in PSPad. I hope you find this as useful as I have.

Here's the latest version for you:

Application info
Home page: www.phdesign.com.au
Project page and download: www.phdesign.com.au
Online docu: www.phdesign.com.au
Download size: ~85 kB
State: Stable

Screenshot:
image
www.phdesign.com.au

- - -

History:

New version released phReplace 2.0.24 (19. Dez 2009)

* Handling an exception that occurs in the vbscript Regex object when using a badly formed regular expression (e.g. reader.(\w)+\(reader.GetOrdinal\(”(\w)+”)); – note I forgot to escape the last parenthesis).

* Added Write to Log option (which defaults to off) to write some debugging log events to a ‘phreplace.log’ file in the same folder as the ‘phreplace.dll’ library. This should help identify the issue for a user where the latest version of phreplace just doesn’t open (no error – no nothing).
You will need to open the phreplace.ini file and change the line:
WriteLog=False
To:
WriteLog=True
to enable the logging feature.

* Not a change but rather a note: Tried to understand the vbscript Regex object’s handling of ‘.’. Apparently it matches a new line (\n) but not a carriage return (\r) which is why doing a replace all with ^(.+)$ was acting strange, try this instead ^([^\r\n]+)$.

- - -

New version released phReplace 2

# Major redesign of code base.
# Created file menu to turn settings on and off as well as access help files.
# Created .chm help files.
# Added search history buttons to recall last 10 search / replace terms.

Read more at www.phdesign.com.au

- - -

New version released phReplace 1.4.3 (23. Juli 2008)

Please note version 1.4.3 has been released which fixes this issue.
search & replace problem: forum.pspad.com

- - -

New version released phReplace 1.4.2 (30. April 2008)

- Stop phReplace defaulting to 'Start from Begining' everytime it is opened.
- Display the search match in the middle of the screen.

- - -

New version released: phReplace 1.4.0 (14. Feb. 2008)

- Released new stable version, only know bug is when word wrap is on.

- - -

New version released: phReplace 1.3.18 (12. Nov. 2007)

This allows you to use backreferences ($1) on a single replace rather than just replace all.

Sorry I haven't got this working with Vista yet, I haven't got a copy of Vista to test with unfortunately.

- - -

New version released: phReplace 1.3.15 (17th July 2007)

Major changes include:
- You can now leave phReplace open while opening, closing or switching files in PSPad.

- Replace all runs Heaps quicker and can be undone in just one undo step.

- Regular Expressions runs in multiline mode. This means that Joe Belmaati's problem searching with ^(\d{4})(.*) now works (see previous posts).

- When searching for new lines with RE the first character of the new line is no longer highlighted.

Also note that to search / replace new lines in regular expressions you may need to use \r\n

See the home page for more history.

.

- - -

Instructions:

Instructions are included in the zip under phreplace.txt
but basically if you extract the zip to the PSPad program folder
it should put the files in the right place,
then close and open PSPad and under scripts
you should see Multiline Search / Replace.
Voila.

.

phReplace should be distributed with 4 files.

1. phreplace.dll
- This file is the guts of phReplace, containing all the processing and user interface.
Being a dll (dynamic link library) this file needs to be registered so PSPad can find it.
In most circumstances as long as it is saved in the PSPad root directory everything should be fine. (e.g. C:\Program Files\PSPad\)

2. phreplace.vbs
- This is the script file which PSPad calls to start phReplace.
This file trys to register the phreplace.dll file if it's not already registered.
Should be located under the PSPad VBScript directory (e.g. C:\Program Files\PSPad\Scripts\VBScript\)

3. phreplace.txt
- Contains instructions to install and run phReplace as well as it's version history.

4. phreplace.ini
- The settings file, if this doesn't exist then phReplace will use the registry to save it's settings.
See the Changing Settings section below for more information.

.

The phreplace.vbs script which is called from PSPad will try to register the phreplace.dll file
automatically (as long as the .dll file is 2 folders above the script folder).

If you have problems loading the library then copy phreplace.dll to your Windows system folder
and type at a command prompt: regsvr32 "phreplace.dll"

To upgrade, overwrite all old files with new version.

.

.
Running phReplace

Once the files are in the correct directories as above
then from the PSPad menu select Scripts > Multiline Search / Replace
or by pressing the key combination Ctrl - Alt - F.

Vista Users:
To run phreplace in vista;

1. In the start menu, search for 'cmd'
2. Right click on the cmd (Command Prompt) and select 'Run as administrator'
3. Type 'regsvr32 {PSPad Folder}\phreplace.dll' (the PSPad folder is c:\program files\pspad by default).
4. Now run PSPad and start phreplace

.

- - -

Changing Settings

phReplace provides a limited number of customisable settings.
These can either be stored in and ini file or in the registry.
To use an ini file, a file called phreplace.ini (can be an empty file) must exist in the PSPad root folder,
however this means that all users of PSPad will see the same settings.
To use the registry simply delete the ini file.

Some settings are:
[Layout] - This contains the last known position of the phReplace screen.
The Save option allows you to specify whether or no to save the position of the phReplace screen.

[Last Search] - This contains information about the last search and the options used.

[Version] - The version number of the last started instance of phReplace

[Settings] - Modeless Form - if this is off the you can't use PSPad while the phReplace screen is open.
Always On Top - sets whether phReplace is always on top of other windows.
Tab Switching - if this is on then pressing the tab button while in a textbox of phReplace will move you
on to the next control.
You can insert a tab character into the textbox by entering shift-tab.

[Shortcut key]
To change the shortcut key for phreplace,
open the file {PSPad Folder}\Script\VBScript\phreplace.vbs
and edit the line that reads
addMenuItem "Multiline Search / Replace", "", "phReplace", "Ctrl+Alt+F"
changing Ctrl+Alt+F to the key combination you want.

.

.

Please see Homepage for newer or more info.

.

- - -
.

Post any bugs, improvement ideas here.

Cheers.

.

Edited 28 time(s). Last edit at 2009-12-20 18:17 by Stefan.

Options: Reply | Quote | Up ^


#2 Re: Multi-Line Search Testers Needed

Posted by: vbr | Date: 2006-10-12 08:28 | IP: IP Logged

I really like the idea as well the implementation. I also would agree with the wishes mentioned in the help file (non-modal dialog & global undo)
Maybe a stupid idea concerning the hack with the selected text:
could you possibly try to change the selection (something like Shift + Left; Shift + Right) while comparing the changed extent of the selected text?
And one more wish (which is probably quite naive one - as I have no experience with VB scripting), could possibly the regular expressions be implemented in the future?

Options: Reply | Quote | Up ^


#3 Re: Multi-Line Search Testers Needed

Posted by: phdesigner | Date: 2006-10-12 10:25 | IP: IP Logged

Hey, I'm glad to hear it worked well for you. Did you have any problems setting it up?
I think you may be onto something with the Shift-Left thing, Perhaps the following would work

Send Command(Shift-Left)
If Length(Selected Text) is greater than it used to be then
Cursor must be at start of text
(so start of selection = Cursor Pos)
Else
Cursor is at end
so start of selection = Cursor Pos - Length(Selected Text)
End If

I'll try doing that, thanks.

Also with Regular Expressions, I don't really use them but I think it would be an easy feature to add so I'll put that in as well.

Options: Reply | Quote | Up ^


#4 Re: Multi-Line Search Testers Needed

Posted by: Joe Belmaati | Date: 2006-10-12 10:55 | IP: IP Logged

I am having am problem with this. The download link takes me straight to some blinking site that offers web hosting.

Options: Reply | Quote | Up ^


#5 Re: Multi-Line Search Testers Needed

Posted by: Joe Belmaati | Date: 2006-10-12 11:10 | IP: IP Logged

OK found the file by browsing to it on your site. Great little application. Here are a couple of observations:

If invoked when no document is open it throws an error message. The regular PSPad S/R simply does not react, which I think it the correct behavior.

The window should remember last state (size and screen position) if possible. It is slightly annoying that the window appears in the bottom right hand corner everytime you invoke it.

When pasting multiplelines that contain tabs into the window the application always throws a "Not found" dialogue.

As you are developing this application, how about solving one of my last remaining gripes with PSPad - support for regular expression S&R that contains the newline character "\n"...

Thanks for a great application.

Options: Reply | Quote | Up ^


#6 Re: Multi-Line Search Testers Needed

Posted by: phdesigner | Date: 2006-10-12 11:28 | IP: IP Logged

I'm having problems creating a link to the download from this forum so you'll need to just copy and paste this link:
(http://www.phdesign.com.au/ download/ phreplace_1_0.zip)
========================
see edited first post for an better download link on www.phdesign.com.au
========================

Joe Belmaati - Thanks for the bugs, I'll try and get these sorted tomorrow along with support for regular expressions. Can't promise too much in regards to '\n' support for regular exp, as I don't really use them myself, but I'll have a crack at it.
I agree that it should remember the last window state. I was toying with the idea of trying to shirnk PSPad a bit when it starts then expanding PSPad again when closed, but it might be quite a lot of work to try and find the right window handle and add logic for the different sizes of PSPad.

Edited 1 time(s). Last edit at 2006-12-26 15:51 by Stefan.

Options: Reply | Quote | Up ^


#7 Re: Multi-Line Search Testers Needed

Posted by: MrSpock | Date: 2006-10-12 12:43 | IP: IP Logged

Here's a small bug with search in selection:

Select some text, in the editor, e.g.:

1
a
3
a
5
6

In this example, search for "a" and replace it with "abc" (something longer or shorter than the text to be replaced), "Selected Text Only" checked. The second occurence of "a" will not be found.

The trouble seems to be that the selection is changed during the replace process.

Options: Reply | Quote | Up ^


#8 Re: Multi-Line Search Testers Needed

Posted by: MrSpock | Date: 2006-10-12 12:53 | IP: IP Logged

Thanks for sharing this most useful thing.
Some minor usability enhancements might include:
* If the selection in the editor is non-empty when the script is called, check "Selected Text Only" option by default. (Standard behavior in most programs.)
* If the "Search" text box in the dialog is not empty when it is started, select (highlight) all the text in there. This way, the user can start typing his/her search text immediately, overwriting the default.
* Disable the maximize and minimize buttons.
* Make the dialog close on press of the Esc key. (Again, standard behavior.)
* Add keyboard shortcuts (underlined characters) to the buttons.
* Replace the default VB icon -- ideally with a PSPad icon (or none at all).
* Third option on the right side of the dialog: replace "Seach" with "Search". winking smiley

Again, thanks a lot. That's what many of us have been waiting for.

Options: Reply | Quote | Up ^


#9 Re: Multi-Line Search Testers Needed

Posted by: vbr | Date: 2006-10-12 13:57 | IP: IP Logged

Hi, I'm glad to hear, that it shouldn't be very complicated to add the regular expressions, I use them quite often and having them multiline would be great.
The script works well for me (some minor visual glitches e.g. after resizing the dialog aren't important at all).

Maybe the escape key could be bound to cancel the dialog to resemble the standard search and replace dialog.

Assigning some shortcut is also very handy, but it can be easilly modified individually in the script file.

I noticed some kind of slowdown on longer lines, but it's the same like the native function of the editor (actually it's my fault having files with long lines smiling smiley

If the idea with Shift-left, Shift-right etc. worked, both directions have to be used to restore the original selection. Furtheremore, some special cases should be taken into account (cursor at the begining of the file - Shift-left does nothing; cursor at the end of the file - Shift-right does nothing).

I have no idea, how much coding would be necessary to implement this, but what about emulating other standard options - count, copy ...
Or maybe the messages could use come area of the dialog itself instead of separate prompts, as the whole dialog is always visible.

Options: Reply | Quote | Up ^


#10 Re: Multi-Line Search Testers Needed

Posted by: phdesigner | Date: 2006-10-13 11:51 | IP: IP Logged

Hey Guys, thanks heaps for all your input. I'm working my way through all your bugs / suggestions, I'll post a new version up hopefully in a few days time. I'd really like to replace the ctrl-f hotkey for searching but I'm not quite sure how to do it. Can anyone help me here?

Options: Reply | Quote | Up ^


Goto Page: 1 2 3 4 5 6 7 8 9 10 11 ...LastNext





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR