[wingide-users] Re: Shortcut for expanding format for functions, etc.

Ken Kinder kkinder at gmail.com
Fri Jul 11 09:33:47 MDT 2008

Actually, I did my own script ghetto style. (The attach script has
another unrelated method I wrote, to pprint.pformat selected text --
also handy!)

Anyhoo, here's what my script does, but it isn't very robust. If you
have this text selected:

      c=['a', 'b', 'c'],
      d='spam, eggs')

and you run the command, "shorten-method", it is replaced with this

pants(a=1, b=2, c=['a', 'b', 'c'], d='spam, eggs')

Similarly, you can expand the above selected text back to full style
with the method, "expand-method":

      c=['a', 'b', 'c'],
      d='spam, eggs')

The code isn't pretty, but I think it works reliably enough for me. It's
important to note that unlike Wing's cooler methods, mine just works
with selected text, so you have to select whatever you're trying to

It should work for both method declarations and method calls. It tries
to keep a "stack" to decide whether it should mangle text inside quotes,
inline data structures, etc.


On Fri, 2008-07-11 at 08:19 -0600, Ken Kinder wrote:
> ctrl+j is useful, bit it would be useful to have a shortcut to move from
> this:
>     spam(a=1, b=2, c=3)
> to:
>     spam(a=1,
>          b=2,
>          c=3)
> or:
>     spam(
>       a=1,
>       b=2,
>       c=3)
> I'm debating writing a script to do it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pformat.py
Type: text/x-python
Size: 4283 bytes
Desc: not available
Url : /pipermail/wingide-users/attachments/20080711/24af887d/pformat.py

More information about the wingide-users mailing list