问题
Is there any shortcut to automatically indent marked lines in the editor? For example, in MATLAB there is the CTRL+I shortcut.
回答1:
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.
回答2:
You can indent by selecting lines and pressing Tab (Shift+Tab to unindent). With Ctrl+1 you can comment/uncomment lines.
You could've searched for this yourself.
来源:https://stackoverflow.com/questions/37181491/spyder-ide-automatic-indentation