Selective Replace In Files

Find, replace, find in files, replace in files, regular expressions

Selective Replace In Files

Postby amm68 » Tue Feb 22, 2005 5:30 pm

Hi,


I wonder if there's any way to selectively replace in files. A product called SNiFF had this feature, where you would get a list of matches (with the match marked up in color as far as I remember) and then you could right click on the matched line or something similar to either replace or not.

I always have a weird feeling in my stomach when I let it globally replace without being able to control what it really does - and sometimes, regex pattern matching isn't sufficient to differenatiate between what needs to be replaced and what doesn't ...

Macros ? Feature suggestion ?


Thanks
User avatar
amm68
Newbie
 
Posts: 3
Joined: Tue Feb 22, 2005 12:00 am

Re: Selective Replace In Files

Postby mjcarman » Wed Feb 23, 2005 9:23 am

If you want to individually approve each change, don't hit the "Replace All" button. Press "Start" instead.
User avatar
mjcarman
Power User
Power User
 
Posts: 124
Joined: Thu Feb 10, 2005 12:00 am

Re: Selective Replace In Files

Postby amm68 » Wed Feb 23, 2005 10:00 am

There is no Start button in the Replace In Files dialog ...
User avatar
amm68
Newbie
 
Posts: 3
Joined: Tue Feb 22, 2005 12:00 am

Re: Selective Replace In Files

Postby jefftaylor » Tue Jan 31, 2006 3:34 pm

:?: Did anyone ever answer this question? This is one of my most missed features since I moved over to Ultraedit from CodeWright.
User avatar
jefftaylor
Newbie
 
Posts: 1
Joined: Tue Jan 31, 2006 12:00 am

Re: Selective Replace In Files

Postby Mofi » Wed Feb 01, 2006 8:23 am

A possible workaround:

Close all open files. Then use Find In Files instead of Replace In Files and and let the search result be captured to the output window. Now you can evaluate the lines with your search string. If a line should be changed, double click on the line with the file name and the file will be opened. After opening all files where the replace should be done run a simple normal Replace with Replace All on all open files.

This workaround will not work if you have more than 1 search hit in a file and not all strings should be replaced by the new string in this file. Maybe you will find a better regular expression search string which only finds the strings which should be replaced.

An other workaround which does not have the limitation described above would be to use a macro. First run the Find In Files and capture the search results to an edit window. Look at the lines and delete those lines, where the replace should not be done. The macro now could open the remaining files, searches for each line and replace the string in this line. Maybe also GotoLine with the number in the clipboard (taken from the search result edit window) works, but I have never tested it.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4062
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Find/Replace/Regular Expressions