Vim Paste Indentation Messed Up (Staircase Effect)
Workaround available Linux, macOS, WSL Updated October 21, 2026
Quick answer
Autoindent re-indents each pasted line. Use :set paste before pasting (and :set nopaste after), or paste from the clipboard register with "+p.
Most likely fix: Toggle paste mode.
Symptoms
Code pasted from the browser into Vim drifts further right on every line, comments get repeated, or mappings fire during the paste.
Why it happens
- Terminal sends pasted text as typed keys, so autoindent/smartindent apply
- Terminal or tmux doesn't support bracketed paste
- Older Vim builds without the bracketed-paste fix
How to fix it
Try these in order — the most common fix is first.
1. Toggle paste mode
- :set paste
- Enter Insert mode and paste
- :set nopaste afterwards (paste mode also disables mappings)
2. Map a toggle key
- Add set pastetoggle=<F2> to ~/.vimrc
- Press F2 before and after pasting
3. Paste from the register instead
- In Normal mode use "+p (needs +clipboard)
- In Insert mode use Ctrl-R Ctrl-P + to insert without re-indenting
4. Use a terminal with bracketed paste
- Modern Vim detects bracketed paste and disables autoindent while pasting
- Make sure tmux and your terminal emulator are up to date
This guide also covers
- vim paste indentation
- vim paste staircase
- vim set paste
- vim paste messes up formatting
Still not working?
If Vim keeps failing, you're not alone. See every Vim problem users report or the alternatives people switch to.
Other Vim errors
- How to Exit Vim (Stuck in Vim)
- Vim Copy to Clipboard Not Working
- Vim E325: ATTENTION Found a Swap File
- Vim E212: Can't Open File for Writing
- Vim E37: No Write Since Last Change
- Vim Backspace Not Working in Insert Mode
- Vim Colors Wrong in tmux
- Why Is Vim So Slow? (Large Files & Long Lines)
- Vim Arrow Keys Insert A B C D
- Vim Requires Python 3 Support Error (YouCompleteMe)
- Vim Modeline Vulnerability CVE-2026-34982