Is there any shortcut to automatically indent marked lines in the editor? For example, in MATLAB there is the CTRL+I shortcut.
Matlab's syntax can match the opening closing statements of if
,while
, for
etc. by looking for end
statements.
In Python these are ambiguous and defined as the nested indentetation. Hence this cannot be reliably implemented as you cannot decide whether the succeeding if
block belongs the the current for
loop or it is the next block, if not indented properly.
If indented properly then Forzaa's answer is the answer otherwise the code is useless anyway and needs to be debugged.
First I will just reconfirm what has been said above, that python is ambiguous about what should be the correct indent. Unfortunately as coming from Matlab I also like Ctrl-I.
Though just check on how Tab and Shift-Tab work in practice, they did a little better than I expected. When I ended up having 2 tabs too much after rearranging code, one Shift-tab brought it back to proper position.
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