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

How do I paste text in insert mode without triggering auto-indent or mappings?

Answer

<C-r><C-o>"

Explanation

The <C-r><C-o>{register} sequence in insert mode pastes register contents literally — without triggering auto-indentation, abbreviations, or mappings. This prevents the mangled indentation you often get when pasting code in insert mode.

The problem

When you use <C-r>" in insert mode, Vim inserts the text as if you typed it. This means:

  • Auto-indent kicks in on every newline
  • Abbreviations expand
  • Insert-mode mappings fire

The solution

" Literal paste — no auto-indent, no mappings
<C-r><C-o>"

" Even more literal — no auto-indent, preserves trailing whitespace
<C-r><C-p>"

Comparison

Keystroke Behavior
<C-r>" Inserts as if typed (triggers indent, abbreviations)
<C-r><C-r>" Inserts literally (no abbreviations/mappings, but still indents)
<C-r><C-o>" Inserts literally, no auto-indent
<C-r><C-p>" Inserts literally, fixes indent to current context

Example

You yank a multi-line code block. In insert mode:

  • <C-r>" — each line gets extra indentation, code is mangled
  • <C-r><C-o>" — code pastes exactly as yanked, clean indentation

Tips

  • This is the insert-mode equivalent of :set paste without needing to toggle it
  • Works with any register: <C-r><C-o>0, <C-r><C-o>a, <C-r><C-o>+
  • Documented under :help i_CTRL-R_CTRL-O
  • Especially important when working with languages like Python where indentation is significant

Next

How do I always access my last yanked text regardless of deletes?