Spellcheck functionality in MATLAB editor

Oleg Komarov on 17 Jan 2013
Latest activity Reply by Rik on 27 Jul 2023

I would like to receive your feedback:
  • would you find useful to have spellcheck built into the MATLAB Editor?
(Consider also an associated toggle, positioned somewhere in the Editor, that would enable/disable the spellcheck for selective use)
Lately, I am writing many quick analyses for publish() and I find that first publishing to MS Word (to check the spelling) and then re-publishing to .html, after manual corrections, disrupts the working.
IMHO, the idea to include spellcheck into the editor would be consistent with the renewed visibility of the PUBLISH tab.
Rik
Rik on 1 Oct 2022
Well, it was mostly the point of me publishing this function, as then you could even use a grammar check (when you open it in Word). I'm still planning to publish the comment stripper I made for minify separate and incorporate it in the splitter function.
Serge
Serge on 1 Oct 2022
It's been almost 10 years and everyone is still waiting...
Duncan Carlsmith
Duncan Carlsmith on 22 Jul 2022
On a Mac, BBEDIT will open a .mlx (which is zip file, (see https://www.mathworks.com/help/releases/R2016a/matlab/matlab_prog/live-script-file-format.html) ) and allow one to edit a file inside. WIth BBEDIT, go to the subfolder "matlab," open the document .xml. Now run the BBEDIT spell check on the xml file and e.g. toggle through using command-; with the spelling window open. The changes you make are reflected immediately in the Live Script Editor. Cool, eh? I guess BBEDIT is saving changes and the Live Editor constantly refreshing. This works great for mere spelling errors.
BBEDIT doesn't do grammar checking. For that, one solution is to export the Live Script to Word and use the Word grammar checker in one window, and effect changes in the Live Editor window. (You can't import an exported HTML or docx Live Script as an mlx.) Grammarly does not appear to work with the MATLAB Life Script Editor. Too bad! Grammarian works however I get some inconsistent behavior, maybe because I'm inexperienced. You drag over a selection in the Live Editor pane, click the Grammarian icon in the menu bar, run spell and grammar check on the selection. When you are done and save, you are prompted to paste the revised text now in the clipboard into the document and it replaces your selection in the Live Editor.
A .mlx is a zip file so if you navigate to a Live Script file fln.mlx in Terminal, make a receiving directory unzipped, and "unzip fln.mlx -d unzipped", you will find the unzipped folder has the contents. Or just unzip -n fln.mlx to place the contents in your working directory. The content files are [Content_Types].xml and three folders: _rels, matlab, and metadata. Inside matlab, find files document.xml and output.xml. You can now edit the document.xml directly in any word processor and then select all the content files and re-zip the contents by using the option key and choosing compress. Rename the resulting .zip to .mlx.
A workflow to do spell checking and grammar without unzipping and rezipping is to open with BBedit the xml file as described above, and then copy paste this file into a Word doc. In word, you will have to 1-time add the corretly spelled MATLAB commands to the dictionary. (Perhaps this could be done en masse using the MathWorks reference function list.) You must also add to the dictionary various xml markup that Word finds foreign. Al this can be done by walking thru each underlined word that is correct and adding it to the dictionary. Once done, Word will offer spelling and grammar check of all comments and code and flag unrecognized variable names and mispelling and questoable grammar in the comments. After fixing all the comments, copy paste that document back in the BBedit window and save. Done! Similarly, one could copy-paste from BBedit into TextEdit with Grammarly. Gramarly works with TextEdit so can offer spellcheck and grammar check. Text edit can't see inside the zipped .mlx to replace there so copy-paste the changed TextEdit text to BBedit and save in BBedit.
Paul de Jong
Paul de Jong on 3 Aug 2021
I desperately need it.
Jan
Jan on 10 Jan 2017
I let Word spellcheck my comments. Therefore I extract the comments at first (which is not trivial) and join them to a single file. If bad spellings are found I use a self-written Matlab tool which searchs in all M-files and creates links in Matlab's command window, such that the line is opened in the editor. You see: this is a mess.
It could be shortend by FEX: SpellCheck . Using NotePad++ would be efficient for some M-files also, but I check the help text of several hundrets files.
My conclusion: A spellchecker for comments is cheap to implement and useful to increase the quality of the documentation of user code.
Jason Nicholson
Jason Nicholson on 27 Feb 2015
Spell check would be great if it only corrected comments. It must not operate on code. I would use it.
I use Notepad++ to spell check my scripts and functions. Below is a screenshot of the spell check in action.
David J. Mack
David J. Mack on 10 Jan 2017
There is a similar option for Visual C++ if I remember it correctly. I think correcting comments & strings would be the first an biggest step, as spelling errors in variable names might be embarrassing w.r.t. other programmers but does not concern the public.
per isakson
per isakson on 27 Feb 2015
Looks like the spell checker of Notepad++ doesn't indicate spelling mistakes in names of variables and functions.
Wolfgang Garn
Wolfgang Garn on 13 Dec 2014
I think a spellchecker would be a big plus.
Sarah
Sarah on 16 Oct 2014
Yes! I have the same issue in publish() as well. I just want spellcheck in the comments. It needs to be able to ignore html and latex though.
Nikolay S.
Nikolay S. on 1 Jul 2014
Totally agree. SO far I'm forced to do it via Word, which is frustrating...
Oleg Komarov
Oleg Komarov on 26 Jun 2014
I totally agree with spell-check on comments only! This is exactly what would make publishing (together with MathJax support) very convenient.