Attention Emacs user: How often do you need to change BIG LETTERS to small letters, or vice versa? Or Maybe You Need To Capitalize Every Word For Some Reason.
Out of the box, Emacs gives you several key bindings to do just that.
These ones work word-by-word:
- M-l
downcase-word - M-u
upcase-word - M-c
capitalize-word
And these operate on a region:
- C-x C-l:
upcase-region - C-x C-u:
downcase-region - C-x C-c:
save-buffers-kill-terminal
That’s a lot of commands, and the last one prompts me to save my buffers for some reason.
The better way
Emacs has a set of DWIM (do what I mean) commands that can change the case of the current region if it is active, and the word at point otherwise. That is to say, the two above command sets are combined into one.
(bind-key [remap downcase-word] #'downcase-dwim)
(bind-key [remap upcase-word] #'upcase-dwim)
(bind-key [remap capitalize-word] #'capitalize-dwim)
Now, go forth and Change some CASE!
Addendum
Thanks to @ross@rossabaker.com for pointing out that this is a good
place to use remap.
Incoming
✏ Edited