How can I reformat code in MATLAB editor?

后端 未结 2 1445
粉色の甜心
粉色の甜心 2020-12-05 08:31

How can I reformat code in MATLAB editor? Other IDEs usually have reformat or format option that arrange position of written codes. Does editor of MATLAB have it? I use MATL

2条回答
  •  广开言路
    2020-12-05 09:07

    A few default formatting shortcuts for the Matlab editor - assuming windows

    ctrl+A - Select all
    ctrl+I - Smart Indend
    ctrl+= - Collapse All (loop control statements)
    ctrl+shift+= Expand All (loop control statements)
    ctrl+] - Increase indent
    ctrl+[ - Decrease indent
    ctrl+J - Wrap comments


    Other useful keyboard shortcuts for Matlab editor

    ctrl+R - Comment out selection (adds leading % to all selected lines)
    ctrl+T - Uncomment selection (removes leading % from selected lines)
    ctrl+K - Kill line (deletes from caret to end of line, if line is empty deletes newline)
    ctrl+M - View or expand current message
    ctrl+F1 - Display function hints


    Additional shortcuts can be found or defined in Prefrences>Keyboard>Shortcuts

    Finally a special mention to ... for line continuation...
    example:

    [output1,output2,output3]=calltoafunctionwithlotsofinputs(...
        intput1, input2, input3, input4, input5, ...
        'property1', propertyvalue1, ...
        'property2', propertyvalue2)
    

提交回复
热议问题