How do I paste a blockwise register without padding lines with trailing spaces in Neovim?
Answer
zp
Explanation
Pastes a blockwise register like p, but skips padding lines shorter than the block's right edge with trailing spaces. This keeps your file clean when working with ragged-right text.
How it works
When you paste a blockwise (visual block) register with p, Vim/Neovim inserts the column of text and pads any line shorter than the block's rightmost column with spaces to maintain the rectangular shape. zp and zP are Neovim-specific variants (added in 0.9) that skip this padding:
zp— paste after cursor, no trailing space paddingzP— paste before cursor, no trailing space padding
The difference is visible immediately in files where trailing whitespace is significant, or when you're inserting into lines of uneven length.
Example
Assume you've yanked a 5-character column with <C-v>2j"ay, producing a blockwise register. The target has three lines of different lengths:
foo
a longer line
ab
Using "ap pads the shorter lines with spaces. Using "azp inserts the column without touching line length:
hellofoo
helloa longer line
helloab
Tips
- Available in Neovim 0.9+ only — not in Vim
- Works with any named register:
"azp,"bzP, etc. - Particularly useful in files where trailing whitespace is prohibited (checked by linters or version control hooks)
- Combine with
<C-v>block selections andI/Afor column insertion without trailing space concerns