Recent

Author Topic: Any way to exclude terms in comments when do Find?  (Read 454 times)

old_DOS_err

  • Jr. Member
  • **
  • Posts: 60
Any way to exclude terms in comments when do Find?
« on: December 05, 2025, 10:03:29 am »
Hi all,

Simple one, hopefully.

I have a lot of text commented out while developing (previous versions, code not needed for testing, etc). I make a lot of use of Ctrl F and Shift Ctrl F to find functions and vars. It would be really helpful if there was a way to exclude any terms in comments, both line and block.

If there was a way to extend the current in-house search that would be acceptable. I have done a lot of text search code and have my own external text search program.

I'm using Windows 10, just in case that makes any difference.

Thanks

Phil

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12014
  • Debugger - SynEdit - and more
    • wiki
Re: Any way to exclude terms in comments when do Find?
« Reply #1 on: December 05, 2025, 11:02:03 am »
For normal search there currently isn't such a feature. Don't know about any plans...

But there is a similar related feature. "Find identifier references" (and "rename identifier refs"). They can include/exclude comments.

However, if you have a local and a global var "foo", then you can only search for one of them. Find Identifier refs works by you going to the declaration of a term, and then finding everything that "jumps to declaration" to this spot.
IIRC, but needs to be checked, that also means that references to overridden instances may not be found.


Yet another options, but only for very local replace editing: Syncro editing. If you want to edit all "foo" inside of one procedure. You can use syncro-edit. You can go to the keymap, there is a way (you need to assign your own keys) to invoke syncro edit "context sensitive", that means terms in comments will form their own groups, not mixing with terms in source, nor with terms in strings.
You can use that up to an entire file, but not cross file boundaries.

old_DOS_err

  • Jr. Member
  • **
  • Posts: 60
Re: Any way to exclude terms in comments when do Find?
« Reply #2 on: December 05, 2025, 12:40:02 pm »
Thanks, just had a play around with that Find Identifier. I think it may have its uses, but it is not as inclusive as Shift Ctrl F, so whilst it removes searches in the comments, there were a lot of entries that didn't show up compared to the general search. Also unlike the general search, it didn't automatically go to the results window, took a few goes before I realised it was opening behind the code window, not on top. Don’t know if there is a setting for that.

I think I need to play around a bit more to understand what it was showing, since it was obviously relative to where it was called, unlike the general search, that doesn't care where it is being called from. During the development phase, I tend to keep most of the relevant files open, except general units, precisely so I can easily check names, for example when I create a new name in a project, var, function, etc, I automatically do Shift Ctrl F to make sure it is unique, except single letters of course :).

Normally I just use the Alt up arrow if I want to get to the declaration.

But thanks for the reply.

Phil

n7800

  • Hero Member
  • *****
  • Posts: 594
  • Lazarus IDE contributor
    • GitLab profile
Re: Any way to exclude terms in comments when do Find?
« Reply #3 on: December 10, 2025, 12:59:05 am »
Also unlike the general search, it didn't automatically go to the results window, took a few goes before I realised it was opening behind the code window, not on top. Don’t know if there is a setting for that.

Yes, that's a bug. I've been wanting to fix it for a while, but the adjacent code was under active development, and I didn't want to introduce conflicts. Maybe I'll find time for a patch now...

It would be really helpful if there was a way to exclude any terms in comments, both line and block.

You can create a feature request on the bug tracker.

I think CodeTools or Highlighter should be used for the implementation. I'm not sure how this will affect dependencies, and whether refactoring will be necessary, or maybe it'll just require a simple callback...

In any case, this task is not for me, but for someone like Martin ))

 

TinyPortal © 2005-2018