当前位置:网站首页>Matlab code format one click beautification artifact
Matlab code format one click beautification artifact
2022-06-25 08:01:00 【studyer_ domi】
MBeautifier It's based on MATLAB Open source one click beautification of source code m Code formatter . It can be directly in MATLAB Use in editor , And can be configured according to user habits .MBeautifier Supported by Matlab The minimum version is R2013b.
MBeautifier The original download address of :https://github.com/davidvarga/MBeautifier
Readers who are inconvenient to download can send keywords in the background of the official account :MBeautifier, You can get the download link of Baidu online disk .
MBeautifier It's based on M-Script Lightweight of MATLAB Source code formatter , But directly in MATLAB Use in editor .

characteristic :
Fill operators and keywords with spaces
Configurable indent characters and levels . Use MATLAB The intelligent indent function of the editor
remove / Add consecutive blank lines
Insert missing element delimiters in matrix and cell array initialization ( comma )
Insert missing consecutive symbolic rows in matrix and cell array initialization
In-lining Continuous line
format MATLAB The current page of the editor or only in MATLAB Select an option in the editor or file
And everything above can be in one XML Configuration in file
Deployment and configuration
Just download zip Extract the file to a specific directory , And then put MBeautifier Add root of to MATLAB route .
![]()

To configure Configuration
You can edit MBeautifier\resources\settings\MBeautyConfigurationRules.xml File to modify the configuration .

Configuration rules
At present, three configuration rules have been implemented :Operator padding rule、Keyword padding rule and Special rule.
Operator fill rule
Every OperatorPaddingRule Represents the formatting rules for a single operator , By a key 、 The string that should be replaced and the string used for replacement .
<OperatorPaddingRule> <Key>NotEquals</Key> <ValueFrom>~=</ValueFrom> <ValueTo> ~= </ValueTo> </OperatorPaddingRule>
The example above shows “ It's not equal to ” Rules for operators .
ValueFrom Node storage operators ~=,
ValueTo The node stores the expected format : Operators should be preceded and followed by white-space character .
Keyword filling rules
Every KeyworPaddingRule Represents the format rules for a single keyword , And by the keyword itself and the required on the right white-space The filled values consist of .
<KeyworPaddingRule> <Keyword>properties</Keyword> <RightPadding>1</RightPadding> </KeyworPaddingRule>
The above example shows the keywords “properties” The rules of .RightPadding The node stores the expected amount of right padding : Keyword should be preceded by a blank character .
Be careful : Not all keywords are listed - Only those that control the filling of meaningful keywords .
Special rules
These rules are basically MBeautifier Switches for certain functions . For details, see the... Of the compressed package README.md file ,
Usage method , Enter directly on the command line to use
At present, four methods are supported :
stay MATLAB Perform formatting on the currently active page of the editor . command :
MBeautify.formatCurrentEditorPage(). By default , The file will not be saved , But it will still open and modify in the editor . You can choose to useMBeautify.formatCurrentEditorPage(true)Syntax saves formatted files .

Yes MATLAB The editor performs formatting on the currently selected text of the active page . command :
MBeautify.formatEditorSelection(). under these circumstances , There is also an optional save mechanism as described above .( I don't know why the running time of this function is long after the actual measurement , Not recommended )Format the file . command :
MBeautify.formatFile(file). It can be done with (1) Use with one parameter : Input file is formatted , And in MATLAB Keep the editor open , Not saved ;(2) The two parameters areMBeautify.formatFile(file, outFile): If possible , Save the formatted file to the specified output file . The output can be the same as the input .file You need an absolute path
Perform formatting on multiple files in the directory . command :
MBeautify.formatFiles(directory, fileFilter). The first parameter is the absolute path to the directory , The second parameter is a wildcard expression ( be used fordircommand ), Used to filter files in the target directory . The file will be formatted in-place( Cover ).

边栏推荐
- 数论模板啊
- 【Unexpected token o in JSON at position 1出错原因及解决方法】
- FFT【模板】
- @The difference between resource and @autowired annotation, why recommend @resource?
- Anaconda based module installation and precautions
- How to create a new branch with SVN
- Six causes of PCB disconnection 2021-10-20
- 洛谷P6822 [PA2012]Tax(最短路+边变点)
- Is it safe to open an account through the haircut account opening link now?
- c#中设置lable控件的TextAlign属性控制文字居中的方法
猜你喜欢

环网冗余式CAN/光纤转换器的CAN光端机在消防火灾联网报警系统中的应用

Cifar-10 dataset application: quick start data enhancement method mixup significantly improves image recognition accuracy

基于STM32MP157调试MIPI-DSI屏幕

Looking for b-end product manager after years? I almost ruined myself

c#磁盘驱动器及文件夹还有文件类的操作

静态网页服务器

將數據導入到MATLAB

Can transparent cloud gateway caniot and candtu record can messages and send and receive can data remotely

剑指offer刷题(简单等级)

c#ColorDialog更改文本颜色和FontDialog更改文本字体的使用示例
随机推荐
深度学习系列45:图像恢复综述
Sword finger offer II 027 Palindrome linked list
电子学:第010课——实验 8:继电振荡器
@Resource和@Autowired注解的不同,为什么推荐@Resource?
Electronics: Lesson 012 - Experiment 11: light and sound
使用Adobe Acrobat Pro调整PDF页面为统一大小
Pcb|about FPC reinforcement type
c#ColorDialog更改文本颜色和FontDialog更改文本字体的使用示例
剑指offer刷题(中等等级)
数论模板啊
年后求职找B端产品经理?差点把自己坑惨了......
Technology blog | how to communicate using SSE
RMQ区间最大值下标查询,区间最值
力扣76题,最小覆盖字串
【补题】2021牛客暑期多校训练营1-3
洛谷P1073 [NOIP2009 提高组] 最优贸易(分层图+最短路)
Pycharm的奇葩设定:取消注释后立马复制会带上#
2160. minimum sum of the last four digits after splitting
【莫比乌斯反演】
MySQL simple permission management
