简体   繁体   English

xcode 指令后的缩进不起作用

[英]Indentation after for instruction in xcode doesn't work

I've been using xcode for some months and this has never happened before, i'm not sure whether i pressed something i shouldn't have or meddled with the settings.我已经使用 xcode 几个月了,这以前从未发生过,我不确定我是否按下了我不应该按下的东西或干预了设置。 Basically i write something like for(int i=1;i<=n;i++) and press enter, and the cursor is on the next line above the instruction, so there's no visual subordination of what I'm about to write next.基本上我写了类似for(int i=1;i<=n;i++)的东西然后按回车,cursor 在指令上方的下一行,所以我接下来要写的内容没有视觉上的从属关系。

If i press the tab key before writing a new instruction below and then write for instance cout<<ni<<endl;如果我在下面写一条新指令之前按 Tab 键,然后写例如cout<<ni<<endl; , the moment I press ; ,我按下的那一刻; , the entire thing is moved in the same column(if that makes sense) again. ,整个事物再次移动到同一列中(如果有意义的话)。 This doesn't happen with other instructions like while or if.其他指令(如 while 或 if)不会发生这种情况。 Help?帮助?

1

Normally indentation occurs when you open a block , as in type { .通常,当您打开一个 block时会出现缩进,如类型{ If you're using a blockless if then the code editor has to figure out after the fact what you're doing.如果您使用的是无块if那么代码编辑器必须在事后弄清楚您在做什么。

I'm not able to reproduce your problem, but here are a few tips:我无法重现您的问题,但这里有一些提示:

To format a selection in the editor在编辑器中格式化选择

Main menu: Editor > Structure > Re-indent ( or ^I )主菜单:编辑器 > 结构 > 重新缩进(或^I

To remove the automatic formatting when pressing ;按下时删除自动格式化;

User Preferences: Text Editing > Automatic indent for : Uncheck the “;”用户首选项:文本编辑 > 自动缩进:取消选中“;” box盒子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM