vimtricks.wiki Concise Vim tricks, one at a time.

How do I paste the unnamed register after transforming it to uppercase?

Answer

:put =toupper(@")

Explanation

Registers in Vim are not only for raw replay; you can treat them as string data and transform them at paste time. :put =toupper(@") reads the unnamed register (@"), converts its contents to uppercase with toupper(), and inserts the result below the current line. This is useful when you already yanked text and want a transformed variant without clobbering any register or editing the original snippet manually.

How it works

  • @" references the unnamed register
  • toupper(...) returns an uppercase copy of that string
  • :put =expr evaluates an expression and inserts the resulting text as new line(s)

Because this pipeline is expression-based, you can swap in other transformations (tolower(), substitute(), concatenation) while keeping the same :put =... shape.

Example

  1. Yank a line: yy (now in unnamed register)
  2. Move elsewhere and run:
:put =toupper(@")

If the register held ReleaseCandidate, Vim inserts RELEASECANDIDATE below the cursor.

Tips

  • Use :put! =... to insert above the current line instead of below.
  • For partial normalization, chain functions: :put =substitute(toupper(@"), '-', '_', 'g').
  • This keeps your original yanked text untouched, which is safer than overwriting registers during one-off transformations.

Next

How do I remove accidental Enter keystrokes from a recorded macro?