Recent

Author Topic: IDE autocompletion: "try except" instead of "try finally"  (Read 489 times)

Fibonacci

  • Hero Member
  • *****
  • Posts: 583
  • Internal Error Hunter
IDE autocompletion: "try except" instead of "try finally"
« on: October 09, 2024, 06:12:56 am »
I wish I could choose in the IDE to autocomplete the "try" word with "except end" block, not "finally end". Is this perhaps already there and I dont see it? Or maybe I could report it as an idea for a dropdown list that would let you choose whats your preference.

1) try - finally
2) try - except
3) try - except - finally

EDIT WHILE STILL WRITING THIS. I found a solution :D So NVM!

Use Code Templates.

If anyone is interested the template is here:

Code: Pascal  [Select][+][-]
  1. try
  2.   try
  3.     $Param()
  4.   except
  5.     $Param()
  6.   end$AddSemicolon()
  7. finally
  8.   $Param()
  9. end$AddSemicolon()

Use it in Tools -> Code Templates, also assign a hotkey in Tools -> Options -> Key Mappings

Bonus template:

Code: Pascal  [Select][+][-]
  1. $Param(VarName) := $Param(TMyClassName).Create;
  2. try
  3.   try
  4.     $Param()
  5.   except
  6.     $Param()
  7.   end$AddSemicolon()
  8. finally
  9.   $Param(VarName,Sync=1).Free;
  10. end$AddSemicolon()
« Last Edit: October 09, 2024, 06:14:49 am by Fibonacci »

ASerge

  • Hero Member
  • *****
  • Posts: 2336
Re: IDE autocompletion: "try except" instead of "try finally"
« Reply #1 on: October 10, 2024, 04:02:26 pm »
I wish I could choose in the IDE to autocomplete the "try" word with "except end" block, not "finally end". Is this perhaps already there and I dont see it? Or maybe I could report it as an idea for a dropdown list that would let you choose whats your preference.
It's very strange. In my IDE, these are tryf and trye.

Fibonacci

  • Hero Member
  • *****
  • Posts: 583
  • Internal Error Hunter
Re: IDE autocompletion: "try except" instead of "try finally"
« Reply #2 on: October 10, 2024, 11:31:04 pm »
Yes, but there is no try-except-finally ;D Two in one. I added "tryef".

ASerge

  • Hero Member
  • *****
  • Posts: 2336
Re: IDE autocompletion: "try except" instead of "try finally"
« Reply #3 on: October 11, 2024, 03:58:01 pm »
Yes, but there is no try-except-finally ;D Two in one. I added "tryef".
I usually only use try finally. Try except, including nested - a rarity.

 

TinyPortal © 2005-2018