Spyder IDE automatic indentation

别等时光非礼了梦想. 提交于 2020-05-29 07:02:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!