I am a newbie to python programming. I find that decreasing the indentation of a block of codes in python is quite annoying. For example, given the following code snippet
for i in range(density): if i < 5: x, y = rnd(0,shape[1]//2)*2, rnd(0,shape[0]//2)*2 Z[y,x] = 1 .... ....
If I comment the if
statement, I have to decrease the indentation for lines in the if block one by one, is there a way that I can do this by one key stroke as I increase the indentation of a block of codes by selecting them and press the TAB key? I guess this is environment dependent, so could you please provide solutions to do so in Eclipse+Pydev, VIM, and other common editors?
In vim, you select the block and then press the < key.
In Eclipse you select it and then press SHIFT + TAB.
Every code editor worth its salt has a one-key way to indent and dedent blocks.
You could also replace the if statement with:
if True: # if i < 5:
and leave everything else alone - no indent/dedent to undo later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With