Align comments

Align comments in file, or all files in folder (and optionally their subfolders)
48 Downloads
Updated 4 Jun 2024

View License

Align comments in file, or all files in folder (and optionally their subfolders)
Before
After
Installation
Copy to MATLAB path ("C:\Users\{USERNAME}\Documents\MATLAB") to allow usage everywhere.
Usage
To format all files in active directory, just run "alignComments" in the terminal.
To format a specific file (or all files in a specific folder), "alignComments("FILE_OR_FOLDER_FULL_OR_RELATIVE_PATH")"
To format a specific set of files (or all files in specific folders), "alignComments({"FILES_OR_FOLDERS_FULL_OR_RELATIVE_PATH"})"
To format files without overwriting (output file will be created with the suffix "_new"), "alignComments({OPTIONAL_FILE_OR_FOLDER},'overwrite',0)"
To format files in subfolders as well, enable recursion by "alignComments({OPTIONAL_FILE_OR_FOLDER},'recursive',0)"
NOTE
While no trouble has been reported with the script, the author cannot guarantee that this script won't break your m files, so you are encouraged to use it first without overwriting, just in case the script parses the m file incorrectly and messes it up. In that case, the author suggests you reach out, so bugs/shortcomings can be addressed.

Cite As

Tanmay Chhatbar (2026). Align comments (https://www.mathworks.com/matlabcentral/fileexchange/129514-align-comments), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023b
Compatible with R2021b and later releases
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
0.972

No functional changes
Updated File Exchange image again

0.971

No functional changes
Updated File Exchange image

0.97

No functional changes
Better formatting
README update

0.96

Fixed a bug that incorrectly parsed inputs when given as a cell array

0.94

Suppress some output on terminal in some cases

0.93

Better help

0.92

Bugfix for 0.91

0.91

Improved detection of spaces, and alignment with the default comment line within MATLAB

0.90

Updated description

0.9