Archaeopteryx Software, Inc.
Take Flight!Search

Home
Wing IDE
News
Support
About Us
Python
Open Source
Store

 Search:
 
 Advanced Search




[wingide-users] Backing up one indent level while entering code?

Stephan R.A. Deibel sdeibel@archaeopteryx.com
Thu, 20 Dec 2001 10:33:15 -0500 (EST)


On Thu, 20 Dec 2001, Gary Bishop wrote:
> But I'm trying to figure out how to best use it. I've got indent width set to 
> 4 and I use spaces only for indentation. I'm in "normal" editor mode.
> 
> Say I'm typing an if statement in python
> 
> if foo:
>     bar()
>     else:
> 
> Of course the else needs to move back to the margin. Backspace only moves me 
> back 1 space. I can type Ctrl-less to move back one level but that is tough to 
> type... The manual talks about Shift-tab inserting a backward tab but it seems 
> to just insert a normal tab.
> 
> What's up? My goal is an easy to type sequence for moving back one level in 
> indentation. What do other people use?

After you typed the "else:", just push the tab key while your cursor is
still on that line. Wing sees that it's a statement that should be back
one indentation level and moves it back automatically.

In general, you can fix indentation with the tab key, which is mapped to
the indent-to-match command.  You can also select ranges of code and push
tab to fix indentation (all lines in the selected block are indented so
the first line is in the right position, the rest retaining their relative
position).

For example, let's say you pasted in some code:

if foo():
  x = 1
    if y == "x":  # These lines
      y = 1       # are a block
      z = 2       # that was pasted
  hoho()

If you select the three indicated lines (the selection doesn't have to be
exact, just so it includes the three lines) and push <tab>, it will adjust
the block to be at the right indentation:

if foo():
  x = 1
  if y == "x":  # These lines
    y = 1       # are a block
    z = 2       # that was pasted
  hoho()

Hope that helps.

- Stephan






Run by Mailman v 2.0.8


Copyright (c) 2000-2002, Archaeopteryx Software, Inc.
Legal Statements