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

How do I evaluate a Vim expression and paste the result directly from a register?

Answer

"=strftime('%F')<CR>p

Explanation

The expression register lets you compute text on demand and insert it without leaving Normal mode workflows. "=strftime('%F')<CR>p evaluates a Vim expression, stores the result in the expression register, then puts it into the buffer. This is useful when you need dynamic values such as timestamps, arithmetic results, or transformed strings while staying inside an operator/motion rhythm.

How it works

  • "= opens the expression register prompt
  • strftime('%F') is the Vim expression being evaluated (YYYY-MM-DD)
  • <CR> confirms and stores the evaluated result
  • p puts that result after the cursor

Example

Given this line with the cursor on DATE::

Release DATE: 

Type:

"=strftime('%F')<CR>p

Result:

Release DATE: 2026-03-27

Tips

  • Replace strftime('%F') with any Vim expression, for example toupper('abc') or line('.')
  • The same expression-register idea also works in Insert mode and command-line mode when you need computed text inline

Next

How do I open another buffer in a split without changing the alternate-file register?