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

How do I paste the contents of a register as a new line below the cursor regardless of the register type in Vim?

Answer

:put {reg}

Explanation

The :put Ex command always inserts a register's content as a new line below the current line, regardless of whether the register holds characterwise, linewise, or blockwise text. This is unlike p, which respects the register type and pastes inline when the content is characterwise.

How it works

  • p — pastes characterwise text after the cursor character (inline); linewise text as a new line
  • :put {reg}always opens a new line below and inserts the register content there, regardless of type
  • :put! {reg} — same, but inserts above the current line (like P for linewise)
  • The unnamed register " is used if no register is specified: :put

This means you can yank a word with yiw (characterwise) and then use :put to paste it onto its own line, which p alone cannot do without extra manipulation.

Example

Yank a function name with yiw (the register now holds a characterwise string like handleClick):

With cursor on: handleClick
  After yiw: register contains 'handleClick' (characterwise)

Now use :put to paste it as its own line:

Before: function handleClick() {}
After :put: 
function handleClick() {}
handleClick

With p, the word would be inserted inline after the cursor character, not as a new line.

Tips

  • :5put a pastes register a after line 5 without moving the cursor — useful for collecting text at a fixed location
  • :$put pastes at the end of the file
  • Combine with = to paste expressions: :put =strftime('%Y-%m-%d') inserts today's date as a new line
  • Use :put _ (black-hole register) to insert an empty line below the cursor — a quick way to add blank lines without leaving normal mode

Next

How do I highlight only the line number of the current line without highlighting the entire line?