缩进文本或代码
键入文本或代码时,会根据所选文本编辑器或代码样式首选项自动缩进。选择Tab 时,选择块可缩进。选择Shift+Tab可减少缩进。
不检测缩进设置
打开文档时,编辑器会通过检查文档内容,尝试自动检测缩进是使用制表符还是空格以及缩进宽度。如果自动检测失败,则使用默认设置。
要关闭自动检测缩进设置,请进入首选项>Text Editor >Behavior 并清除Auto detect 。
修复打开文件中的缩排
要修复当前在编辑器中打开的文件的缩进设置,请使用编辑器工具栏上的Spaces >Document Settings 或Tabs >Document Settings 选择不同的设置。
要修复当前在编辑器中打开的文件的缩进设置:
- 在编辑器工具栏上,选择Spaces 或Tabs ,然后选择Auto-indent Selection ,以使用当前设置自动缩进所选文本。
- 转到Edit >Advanced ,然后选择缩进选项或使用键盘快捷键。
缩进选项
- 要自动缩进高亮显示的文本,请选择Auto-indent Selection 或选择Ctrl+I。
- 要自动格式化高亮显示的文本,请选择Auto-format Selection 或选择Ctrl+;。
- 要调整所选段落的换行,请选择Rewrap Paragraph 或选择Ctrl+E,然后选择R。
- 要切换文本换行,请选择Enable Text Wrapping 或选择Ctrl+E,然后选择Ctrl+W。
- 要在编辑器中显示空白,请选择Visualize Whitespace 或选择Ctrl+E,然后选择Ctrl+V。
- 要清除当前打开文件中的所有空白字符,请选择Clean Whitespace 。
保存文件时自动固定缩进
要在保存文件时根据缩进设置自动固定缩进,请进入首选项>Text Editor >Behavior >Clean whitespace ,然后选择Clean indentation 。选择Skip clean whitespace for file types 以排除指定的文件类型。
在编辑器中显示空白
要在编辑器中显示空白,请转至首选项>Text Editor >Display >Visualize whitespace 。
要可视化缩进,请选择Visualize Indent 。要调整可视化的颜色,请在Font & Colors 中更改编辑器配色方案中可视化空白设置的值。
显示右边距
为帮助您将行长保持在特定字符数,请在Display right margin at column 中设置字符数。要为边距区域使用不同的颜色,请选择Tint whole margin area 。清除它可将边距显示为垂直线。
要在可用时使用上下文特定的边距,请选择Use context-specific margin 。然后,使用ClangFormat ColumnLimit
选项设置页边距。
另请参阅 "C++ 代码样式"、"行为"、"指定Qt Quick 代码样式"和 "键盘快捷键"。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.