Change Text Case in Emacs
To change the letter case in Emacs:
M-u
-(upcase-word)
- will convert following word to UPPER case (or the rest of the current word).M-l
-(downcase-word)
- will convert following word to lower case (or the rest of the current word).M-c
-(capitalize-word)
- will Capitalize the following word (or the rest of the current word).
For example, consider the text The quick brown fox jumped.
If you position the cursor on the q
(fifth column), then M-u
changes quick
to QUICK
, M-c
changes quick
to Quick
, etc.
If you position the cursor on the u
(sixth column), then M-u
changes quick
to qUICK
, M-c
changes quick
to qUick
, etc.
One could probably write an elisp function based on (capitalize-word)
and some heuristics or dictionary look-ups to create a true title case function (e.g., not capitalize a
, an
, the
in the middle of a phrase), but M-c
is a quick and easy approximation.
Also, note that there is a version of upcase and downcase that work on the selection (region) instead of the next word.
C-x C-u
-(upcase-region)
C-x C-l
-(downcase-region)
Of course, if you're using "CUA Keys", you can't easily type C-x
without invoking "cut".