Friday finking: IDE 'macro expansions'

Thomas Passin list1 at tompassin.net
Thu Mar 16 19:54:21 EDT 2023


On 3/16/2023 6:55 PM, dn via Python-list wrote:
> It is a long, long, time since I've thrown one of these into the 
> maelstrom of our musings.
> (have the nightmares receded?)
> 
> 
> Do you make use of your IDE's expansionist tendencies, and if-so, which 
> ones?
> 
> 
> NB this is where vi/emacs enthusiasts start chuckling (polite term for 
> 'insane cackling'). Hence the question's limitation to IDEs, cf 'editors'!
> Also: I'm talking 'PyCharm' because of the story, but others use Codium, 
> Sublime Text, etc - which presumably offer equivalent features.
> 
> 
> Was helping a friend install PyCharm. Jumped into the Settings. Isn't it 
> incredible how many there are?
> 
> Idly noted that there are two short-cut or macro-expansion types of 
> facilities:
> - Postfix Completion, (nothing to do with email or polish notation) and
> - Live Templates (again, we're not talking about jinja2)
> 
> 
> With both, one types an abbreviated-name and the IDE will expand it into 
> appropriate code. For (LiveTemplate) example, typing compli and pressing 
> Tab induces PyCharm to add the following to the program[me]:
> 
>      [ ! for ! in !drop-down menu! if ! ]
> 
> It offers further typo-saving through the drop-down menu which lists a 
> bunch of likely (iterable) candidates from amongst previously-written 
> code. The action continues after selecting from the menu, by inviting 
> completion of the other ("!") placeholders, in-turn.
> 
> 
> I haven't made use of such a tool, to-date - OK, yes, I have practised a 
> high typing-speed (and accuracy). Puff, puff...
> 
> Also, at the time, I'm thinking in 'code', rather than about what tool 
> might implement said ideas.
> 
> 
> Do you make use of such expansionist-tendencies?
> 
> Do you make use of other powerful features within the IDE, or are its 
> editor functionalities employed at pretty-much the NotePad level?

In general, I don't like a lot of popups and code completions, so I tend 
to avoid them.  I don't even like automatic parens or brace insertion. 
They distract me, and often put the cursor somewhere I don't want it.

Of course, for Python code I do like automatic indentation after a 
colon: if the cursor ends up in the right place, then I'm happy.

If I'm using a plain editor, then I usually like EditPlus.  It's not 
free but the cost is low and it's well worth it (but Windows only).  It 
knows about file types, and can do various insertions and completions if 
you want (as I said, I mostly don't).  I also use Notepad++, but I more 
often go with EditPlus.

What I find more useful is matching brackets/parens/braces.  Not 
inserting them but highlighting or (better) jumping to the matching one 
when asked.

Otherwise I'm usually working in the Leo Editor, which is hard to 
explain in a few words but is a real gift, especially for Python 
programmers.  It does have an abbreviation capability that I use a 
little, but so far mostly for inserting symbols like math and Greek 
letters.  Leo is written in Python (with a Qt GUI) and you can easily 
get access to all its internals, so once you learn something about how 
it works, you can create scripts to do almost anything you want.

The Leo Editor is an MIT-licensed project on GitHub (I know I sound very 
positive but despite that, it's not my project; it really can grow on 
you - if you are willing to climb the learning curve).



More information about the Python-list mailing list