MATLAB: What do you think of “Did you mean clearvars -except”…..

clearvarsdid you mean?enhancementMATLAB

I often use clearvars -except, e.g.
clearvars -except temperature loads speeds
but because I don't sub-vocalize the hyphen I too often accidentally type
clearvars except temperature loads speeds
and then I have the unfortunate result of deleting the very same variables I meant to retain!
My proposal is that when one doesn't have a variable "except", the "Did you mean" feature should kick in with
Did you mean clearvars -except temperature loads speeds
Anyone else had this? What do you think of this suggestion?

Best Answer

The suggestion is interesting but not possible to implement. "did you mean?" is implemented with a try-catch block but your clearvars example never throws an error. The only possible implementation would be to modify the clearvars function to have a special case for the variable "except" which would be an incompatibility.