Ian Branch 131 Posted 16 hours ago Hi Team, During development/rework I often need to select a full procedure or function for delection or replacement. Delphi doesn't seem to have the ability. Is there an IDE plug-in that will allow me to select the current procedure in total? I found in 'Select Current Methody Body' in CnPack but it literally only selects the body of the method. Regards & TIA, Ian Share this post Link to post
havrlisan 31 Posted 14 hours ago If you're using MMX (which I highly recommend), you can use the "Delete Entity..." feature which deletes the current entity your caret is on: interface, class, property, method, field, etc. Not sure if it's the default shortcut, but mine is "Ctrl+Shift+Delete". For fun, here are my MMX usage statistics for features that have been used 1000+ times (Delete Entity is in top 3): Share this post Link to post
Ian Branch 131 Posted 13 hours ago Tks havrlisan. I found that one and at times it will be useful. Sometimes I just want to select the method and comment it out while I try an alternative version of the method. Share this post Link to post
havrlisan 31 Posted 13 hours ago 1 minute ago, Ian Branch said: Sometimes I just want to select the method and comment it out while I try an alternative version of the method. Even that is possible with MMX, with the feature called "Comment member(s)..." in the "Text Tools" group. I know I manually set the shortcut of that one to "Alt+Shift+X". With that one, you can even edit the "TODO" comment that gets added, in MMX > Properties >Editing (Pascal group), and there you'll see the setting "Text to insert when commenting entity" in the last section, "Insert Text When Commenting". Share this post Link to post
Ian Branch 131 Posted 13 hours ago Tks. Close ,but not quite. If I comment a method with it, it also comments the declaration in the class. 😞 Share this post Link to post
havrlisan 31 Posted 13 hours ago Just now, Ian Branch said: Tks. Close ,but not quite. If I comment a method with it, it also comments the declaration in the class. 😞 I didn't realize you meant only the implementation. In that case, I'd use the plain simple line commenting: Delphi has that feature set to shortcut "Ctrl+/", where / character is on numpad. MMX has the feature "Toggle Comment Selection", which acts very similar. You can assign a custom shortcut to that one. GExperts also has a similar feature; not a toggle comment, but comment and uncomment. You can find it under "Editor Experts", and assign a custom shortcut as well. Share this post Link to post
Ian Branch 131 Posted 13 hours ago Tks. ATT I manually select the whole method then use Ctrl-/. My issue is that with large methods it would be easier if the method could be readily selected, rather than having to manually select from start to finish. Share this post Link to post
Uwe Raabe 2113 Posted 12 hours ago 57 minutes ago, Ian Branch said: My issue is that with large methods it would be easier if the method could be readily selected, rather than having to manually select from start to finish. MMX has an action Select Method Body (under Text Tools...), although that spares the variable declarations before the begin. There is no shortcut by default, but that can be configured. Share this post Link to post
Ian Branch 131 Posted 12 hours ago Hi Uwe, Yes I have investigated that one, but I want the whole method, not just the body. Share this post Link to post
Stano 145 Posted 11 hours ago If I understand correctly, use this procedure: collapse the entire method - the + sign at the beginning of the method select the resulting line and you're done Share this post Link to post
Ian Branch 131 Posted 11 hours ago Hi Stano, If I collapse it and the ctrl-/ it comments the first line and opens the rest. Share this post Link to post
Stano 145 Posted 11 hours ago Of course, I got it mixed up. I meant copy Ctrl+C. That's not what you want. Sorry. Share this post Link to post
Uwe Raabe 2113 Posted 9 hours ago Just to make sure I understand correct: You want to comment the implementation of a method, but not the declaration? 6 hours ago, Ian Branch said: During development/rework I often need to select a full procedure or function for delection or replacement. In such a case I usually extract the current method with MMX into a new one. Let's assume the method is named MyMethod. Then I extract the content in question (can be the whole) into a new method MyMethodA. If configured accordingly that leaves a single call to MyMethodA in the body of MyMethod. Then I can either comment that call or replace it with another call to MyMethodB, which is implemented differently. This has the advantage that I can call either method depending on some condition or configuration setting to test the behavior without re-compiling. 1 Share this post Link to post
Ian Branch 131 Posted 4 hours ago Hi Uwe, I tend to leave the method there in its original place but commented out so that if the test replacement method doesn't work out it is a 'simple' matter to delete the new and uncomment the old. The annoyance being selecting the entire method for some action. Share this post Link to post
Stano 145 Posted 1 hour ago It didn't leave me alone. I tried the collapsed CnPack function. I don't know if it will help you somehow. Anyway, you need to edit the beginning and end of the method. In the picture is the result. Coding toolset -> Comment Code Share this post Link to post