Jump to content
PeterPanettone

A simple Code Editor trick to quickly jump to predefined locations in a huge unit

Recommended Posts

OK, here is another simple trick I often use to quickly jump to specific locations in very large units (e.g., 20,000 lines, like in my upcoming "Advanced Windows Start Menu"):

We could use simple bookmarks for this purpose, but I often clear them all after finishing a specific short-term task. So we need something more persistent:*

 

*Prerequisites: CnWizards

 

1. Create these kinds of comments on the locations you want to jump to quickly:

 

implementation // toc_implementation
public // toc_public
// toc_PrivateVariables
private // toc_private
TForm1 = class(TForm) // toc_MainFormClass
// etc.

 

2. Then put all these TOC items at the very top of your huge unit:

 

{TOC:
toc_implementation
toc_public
toc_PrivateVariables
toc_private
toc_MainFormClass
}

 

3. Then, when you need to quickly jump to one of these locations in your huge unit:

 

- Press CTRL+Home to jump to the top of the unit
- Double-click one of the toc_ items to select it
- Press F3 to quickly jump to this location

 

This will save you a lot of search time!

 

Edited by PeterPanettone

Share this post


Link to post
9 hours ago, PeterPanettone said:

- Double-click one of the toc_ items to select it
- Press F3 to quickly jump to this location

Hm, interesting. I didn't know that F3 automatically searches the next occurrence of the selected text.

[testing it]

No, it doesn't, at least not in my Delphi 13 installation. I have to press Ctrl+F and enter first.

 

😕 ??

Share this post


Link to post
1 hour ago, dummzeuch said:

Hm, interesting. I didn't know that F3 automatically searches the next occurrence of the selected text.

[testing it]

No, it doesn't, at least not in my Delphi 13 installation. I have to press Ctrl+F and enter first.

 

😕 ??

It doesn't??

 

In my Delphi 12.2 and Delphi 13, it does!

This is very strange!

Share this post


Link to post

I've found it: F3 automatically searches the next occurrence of the selected text only if CnWizards is installed.

 

I've tested it by unloading CnWizards. When CnWizards is not loaded, then F3 on the selected text displays this message:

 

image.thumb.png.749ce23070a3b7d15c4107097f36b018.png

 

And then, when clicking the "Yes" button after having checked "Wrap around without asking", this message is displayed:

 

image.thumb.png.8fcf4049e95cc7bddc3781a2792d89f1.png

 

This could be a bug in the Delphi IDE that CnWizards resolves.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×