Menu

#66 Find and Replace (poss. with regex)

3.0
closed-fixed
None
5
2014-04-21
2005-06-13
No

OmT currently does not have a Find/Replace set of functions. I think this would be useful, especially with post-editing. There should be options for Find, Find Next, Replace Current and Replace All. Possibly there should be a warning popping up when selecting Replace All.

Find/Replace can be done in two ways (and I suggest both are implemented):

1. The most simply way to implement this would be to launch a small window with two fields (Find What and Replace With), four buttons (Find, Find Next, Replace Current and Replace All), and a tickbox for "All Documents in Project" (not ticked by default). This feature would find instances in the current document or all documents and open the segment (optionally highlighting the find phrase if possible). The user then uses the four buttons to replace or not replace.

2. For regex find/replace, it may be easier if users do it in a two-step process: first they do a normal Find (there should be a tickbox "Show only target text"), and then when the find results are displayed in the Find window, they do a Replace (also with four options Find, Find Next, Replace Current and Replace All).

Discussion

  • Henry Pijffers

    Henry Pijffers - 2006-02-23

    Logged In: YES
    user_id=545103

    I second this. I could very well use a find & replace
    function right now. I have to find & replace some 30 or 40
    occurrences of strings ending in door/deur, and insert one
    friggin' space...

     
  • Jean-Christophe Helary

    • summary: Find and Replace (possibly with regex) --> search features part 4 Find and Replace (poss. with regex)
     
  • Jean-Christophe Helary

    • milestone: --> 442218
     
  • Jean-Christophe Helary

    • milestone: 442218 --> 258669
     
  • Nobody/Anonymous

    A search and replace is really a must-have to be able to realy use OmegaT.
    Having to go do such tasks outside does not make sense.

     
  • Nobody/Anonymous

    I second this too. Not have a search and replace makes OmegaT look very bad when I present it to someone.

     
  • Didier Briel

    Didier Briel - 2010-04-19
    • milestone: 258669 -->
    • summary: search features part 4 Find and Replace (poss. with regex) --> Find and Replace (poss. with regex)
     
  • anatolica

    anatolica - 2010-12-14

    Is there any way to implement find and replace with the current OmegaT development? This would be great as now we have very powerful filtering options and export to text scripts, etc., this would be an invaluable addition to OmegaT.

     
  • Didier Briel

    Didier Briel - 2013-11-29
    • assigned_to: Alex Buloichik
    • Group: --> future
     
  • Didier Briel

    Didier Briel - 2014-02-03
    • status: open --> open-fixed
    • Group: future --> 3.0
     
  • Didier Briel

    Didier Briel - 2014-02-03

    Implemented in SVN (/trunk).

    A Search and Replace entry was added in the Edit menu. The default shortcut is Ctrl+K (Ctrl+H could not be used, as it used natively by Java as an alternative to Backspace). It calls a window similar to the exiting Search window, but with parts not applicable to a Search and Replace operation removed: it is only be possible to search in Memory.

    A “replace” field (identical to the Search for field) was added. If Regular expressions is checked, it is possible to enter regular expressions in this field, otherwise the content of the field will be treated as a string literal.

    Pressing Search will result in the usual search results being displayed.

    If there are search results, two additional buttons will be displayed: Replace All and Replace.

    If Untranslated is checked in the search options and a search result applies to an untranslated segment, then the source segment will be copied to the target segment before the replace operation occurs. That way, it will be possible to do search and replace operation on untranslated text, similarly to what is done when “pre-translating” terminology in a word processor. If no replacement is done to a given segment, the target segment will be “emptied”, i.e., it will remain untranslated.
    (Unless "Allow translated segments to be equal to source" is checked, in which case the segment will be recorded.)

    If Replace All is pressed, a confirmation dialog will appear: You are going to modify xxx segments (xxx being the number of segments returned by the search results). Do you want to continue? with two buttons Yes and No. Pressing Yes will apply the replace strings to all segments where appropriate, pressing No or Escape will cancel the replacement.

    If Replace is pressed, OmegaT will switch to the Editor in filter mode (i.e., only segments corresponding to the search results will be displayed), positioned on the first segment containing the search expression, the search expression being highlighted in blue. The Editor will contain three additional buttons: Skip, Replace Next and Cancel, in a bar at the top of the Editor’s pane. As a “side-effect” of the implementation, a Remove Filter button will be added in a bar at the top of the Editor’s pane whenever the Editor is in filtered mode. Currently, the only way to remove a filter is to go again to the Search window and to press on Remove Filter, which becomes impossible if the Search window is closed.

    If Cancel is pressed, OmegaT will remove the filter in the Editor and return to the Replace window.
    If Skip is pressed, OmegaT will go to the next segment, switching to another document if appropriate.
    If Replace Next is pressed, OmegaT will replace the first search expression of the segment by the replace expression (which will be visible in the segment). It will go to the following segment when all search expressions in the segment have been skipped or replaced.

    The replace operation will be cursor-dependent. I.e., the user will be able to go manually to a segment (thus skipping all the previous ones) and carry on the replace operation from there.

    Didier

     
  • Kos Ivantsov

    Kos Ivantsov - 2014-02-03

    Is it possible to use grouping for replace? For example, if I needed to replace #3 with № 3, I'd search for ^#(\d+) and replace with № $1, but $1 seems to get interpreted literally, and not as a placeholder for the first group.

     
  • Didier Briel

    Didier Briel - 2014-02-03

    Regexp are used for searching, not for replacing.

    Didier

     

    Last edit: Didier Briel 2014-04-19
  • Didier Briel

    Didier Briel - 2014-02-03

    During this development, part of the search window was clarified.

    Instead of checkboxes, radio buttons have been used. You can now search in Source and translation, Source only, Translation only.
    You can also search Translated or untranslated segments, Translated only, Untranslated only.

    Didier

     
  • Jean-Christophe Helary

    So, it is not possible to use references to the search in the replace field ?

     
    • Didier Briel

      Didier Briel - 2014-02-03

      No.

      Didier

       
  • Kos Ivantsov

    Kos Ivantsov - 2014-02-03

    Can it be requested to enable RegEx for replacing too? Should such request be filed as a separate RFE or can it be asked for here?

     
    • Didier Briel

      Didier Briel - 2014-02-03

      It's better to make a separate RFE, as this one will be closed for the next release.

      Didier

       
  • Didier Briel

    Didier Briel - 2014-04-14
    • status: open-fixed --> closed-fixed
     
  • Didier Briel

    Didier Briel - 2014-04-14

    Implemented in the released version 3.1.0 of OmegaT.

    Didier

     
  • Didier Briel

    Didier Briel - 2014-04-21

    In the replace toolbar, "Cancel" will be replaced by "Finish" (as of 3.1.0 update 1), because "Cancel" could lead to believe that changes already done would be
    undone.

    Didier

     

Log in to post a comment.