matlab 注释 自动换行,Matlab将注释调整为每行一定的长度

本文介绍如何在MATLAB中保持注释的自动换行和手动缩进一致性,当你需要修改注释时,如何高效地调整以保持最大行长度,同时保持代码整洁。步骤包括:初始添加时使用'wrapcomments'命令,然后手动调整首行,最后再次格式化以达到最佳效果。
摘要由CSDN通过智能技术生成

我喜欢MATLAB在每行的某个限制上自动换行注释.现在让我们假设我添加了以下注释:

% a) this is a test comment. this is a test comment. this is a test comment

% this is a test comment. this is a test comment. this is a test

% comment! this is a test comment!

在开头用手动缩进(以适应a)).现在,当我需要更改一些评论时,例如在第一行插入一些单词,第一行变得太长.如何自动将其新格式化为正确的最大值.线长但仍然手动缩进?

有没有自动的方法来做到这一点?

最佳答案 我认为你能做的最好的事情需要你做三个步骤.

当您最初添加一些文本时,它看起来像这样:

% a) this is a test comment. this is a test comment. ADDED TEXT this is a test comment

% this is a test comment. this is a test comment. this is a test

% comment! this is a test comment!

首先,选择文本(或通过CTRL a选择整个文件),然后使用CTRL J发出“wrap comments”命令.现在你的文字看起来像这样:

% a) this is a test comment. this is a test comment. ADDED TEXT this is a

% test comment

% this is a test comment. this is a test comment. this is a test

% comment! this is a test comment!

其次,您必须手动缩进第一行,因此文本如下所示:

% a) this is a test comment. this is a test comment. ADDED TEXT this is a

% test comment

% this is a test comment. this is a test comment. this is a test

% comment! this is a test comment!

第三,选择文本并再次使用CTRL J.您的文字将如下所示:

% a) this is a test comment. this is a test comment. ADDED TEXT this is a

% test comment this is a test comment. this is a test comment. this is a

% test comment! this is a test comment!

它并不完美,但它在Matlab编辑器中就像我所知道的一样好.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值