Tip71: Edit the Contents of a Macro
January 12, 2021 ยท View on GitHub
The Problem: Nonstandard Formatting

~
toggles the case of the letter under the cursor.
vU
uppercase the letter under the cursor.
Paste the Macro into a Document
:put a
paste the macro into the document(below the current line).
"appaste the contents of a register after the cursor position on the current line.
Edit the Text

Yank the Macro from the Document Back into a Register
"add
the dd command performs a line-wise deletion, the register contains a trailing ^J character. this character represents a newline.
As a precaution, using a character-wise yank:

"ay$
yank every character on that line except for the carriage return.
Discussion
:let @a=substitute(@a, '~', 'vU', 'g')
perform the same edit as before.