How can I reverse the case of a selected string?

vERY OFTEN i FIND THAT i ACCIDENTLY HAVE THE CAPS LOCK ON.
iS THERE ANY WAY TO EASILY REVERSE THE CASE OF A SELECTED STRING?
i'VE FINALLY REACHED THE LIMIT OF MY PATIENCE W.R.T. THIS.
tia
gREG

 Accepted Answer

dpb
dpb on 13 Jan 2015
Edited: dpb on 13 Jan 2015
Wrap in a function...
>> s='gREG';
>> ilo=lower(s)==s;
>> s(iup)=lower(s(iup));
>> s(ilo)=upper(s(ilo));
>> s
s =
Greg
>>
Can be done w/ arrayfun and anonymous function on the fly, too...
ADDENDUM
Thought I had completed my thoughts but see I hadn't...
I presume, however, you're looking for this in the editor and there I have yet to figure out how one can extend it or bind a key to a m-file or the like. One can change key bindings to defined actions albeit it's a klunky interface to find them but afaict there's no extensibility.
It's why for coding "in anger" I don't use the Matlab editor but one of long personal familiarity.
If there is a way to customize the builtin editor, I'd surely like to know how and where it is documented, too....

3 Comments

Thanks for your time. I was obviously looking for a mouse click or single key solution.
It just seems so weird that there is none. So I checked Notepad and Wordpad.
I couldn't find it there either.
Seems strange because I think that I used to have computer/software that had that capacity. Maybe back in my UNIX days before retirement?
Thanks again
Greg
Indeed, it seems to me that programmers' editors have become "braindead" with the advent of Microsoft.
I've mentioned before I use the old DOS Brief editor as it has all these things and more.
Others use emacs or their own of choice; I don't know it well enough but there are still tools out that do have the facilities either builtin or allow easy extension.
One of the other features I miss routinely within the MS world is there is no column select feature; only by line which makes data file editing a real pain...there are just too many things to list that the fancy graphics coloring and all just doesn't make up for it as an editor. The integration with the debugger is a_good_thing (tm); it's just too bad one has to use multiple toolsets to have all the desired (in my mind necessary) features for serious coding.
Others use emacs or their own of choice; I don't know it well enough...
I looked; while base emacs does include word-casing as well as selected upper/lower, it doesn't appear to have a builtin flipcase. However, it is easily extensible as opposed to the Matlab/TMW-supplied editor (again, unless it is a hidden option I'm just unaware of).

Sign in to comment.

More Answers (0)

Categories

Asked:

on 13 Jan 2015

Commented:

dpb
on 14 Jan 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!