Recent

Author Topic: Search/Replace  (Read 3503 times)

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Search/Replace
« on: September 07, 2021, 07:15:43 am »
I use Mageia 8 KDE.

Have several pages in my code : I tried to rename a variable by using Search/Replace in the Global state. (I changed 'Selected Text' to 'Global' after the first - maybe second - time).

It didn't do the job 100% the first time. Had to use Search to determine the location(s) of unchanged page(s). Took 3 or 4 goes until Search found zero cases of the old variable!

Presumably it should work 100% the first time. Maybe I should have set Global before even starting?

Perhaps the developers will be interested in this[?].

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Search/Replace
« Reply #1 on: September 07, 2021, 10:06:39 am »
Lazarus IDE has a tool for this: rename identifier.
You can specify if this is for current unit only or for whole project.

I don't think the FP IDE has such a feature.

Bart

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Re: Search/Replace
« Reply #2 on: September 12, 2021, 05:04:06 am »
Bart > somewhat confusing to have apparently two ways of renaming : (rename identifier) / (Search/Replace).

I wish to reiterate that the 'global' search/replace does not work 100%; I've had to repeat several times (by changing editor pages) to achieve a 100% success. Obviously unsatisfactory and certainly frustrating.

Can't this be fixed? I'm not sure if this is a new problem; users don't often need to do renames so it may have escaped previous attention :(.

dseligo

  • Hero Member
  • *****
  • Posts: 1221
Re: Search/Replace
« Reply #3 on: September 12, 2021, 10:50:51 am »
Can't this be fixed? I'm not sure if this is a new problem; users don't often need to do renames so it may have escaped previous attention :(.

I didn't notice this problem, and I use search/replace quite a lot.

Can you make example project and exact steps to show and reproduce this problem?

dseligo

  • Hero Member
  • *****
  • Posts: 1221
Re: Search/Replace
« Reply #4 on: September 12, 2021, 10:53:24 am »
It didn't do the job 100% the first time. Had to use Search to determine the location(s) of unchanged page(s). Took 3 or 4 goes until Search found zero cases of the old variable!

Did you have 'Prompt on replace' checked? Did you press 'Replace All' button?

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Search/Replace
« Reply #5 on: September 12, 2021, 11:43:46 am »
I tried to rename a variable by using Search/Replace in the Global state.
I would never do it this way because Search/Replace, even when set to "Global", operates only on the currently selected unit, but an identifier can exist also in other units or in the lfm file. And Search/Replace is "stupid". As Bart already noted, the better option is to use the "Refactoring" > "Rename Identifier" item in the context menu. This is really an amazing feature!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9869
  • Debugger - SynEdit - and more
    • wiki
Re: Search/Replace
« Reply #6 on: September 12, 2021, 12:40:48 pm »
1) How to reproduce?

2) Search/replace is current file only (ever if global). "Find in files" has a replace across several files.

3) Global, for the current file. Make sure to also change the origin to "begin of text" or to "wrap around"


Rename Identifier is a different behaviour.

Say you have a variable FFoo in 2 different classes. Rename Identifier will work out to which class each occurrence of FFoo belongs, and only replaces those that belong to the class you selected (when starting rename identifier). So it is a "smart" replace.

 

TinyPortal © 2005-2018