How do I paste a register's content in Insert mode without Vim adjusting the indentation?
Answer
<C-r><C-o>{register}
Explanation
The standard <C-r>{reg} pastes register contents in Insert mode, but Vim may auto-indent multi-line text to match the current indentation level — sometimes mangling pasted code. <C-r><C-o>{reg} (Control-R, Control-O) inserts the register text literally and blockwise, exactly as stored, with no indentation or line-break adjustments.
How it works
<C-r>{reg}— pastes register, subject totextwidth,autoindent, and other formatting options<C-r><C-o>{reg}— pastes register literally (no formatting), cursor stays in place<C-r><C-p>{reg}— pastes with indent correction applied (fixes indentation to match context)<C-r><C-r>{reg}— pastes with special characters interpreted (useful for registers containing Vim key sequences)
The <C-o> variant is most useful when pasting pre-indented multi-line code blocks from a named register or the clipboard.
Example
You have yanked a Python code block into register a:
def process(data):
result = []
for item in data:
result.append(item)
return result
Inside a deeply indented context, <C-r>a might add extra indentation. Use <C-r><C-o>a to paste the block exactly as yanked.
Tips
- For the unnamed register:
<C-r><C-o>"— literal paste of the last yanked/deleted text - For the system clipboard:
<C-r><C-o>+— literal paste from the+register - When pasting from the system clipboard into a terminal Vim without bracketed paste mode,
:set pasteis the alternative to prevent cascading indentation issues - In Neovim,
<C-r><C-o>is the preferred method over:set paste(which Neovim discourages)