Whenever I paste something in a source code buffer it is automatically re-indented. This is great sometimes, if I'm pasting a complete block of code or a single self contained line for example, but it's awful other times. For example I often assemble fragments together from various places and usually they have at least some existing indentation that I'd prefer to keep.

I've been told I can pass the universal argument to the past command to paste without indentation but "SPC u p" doesn't seem to do anything different.

Is there a way to turn off auto-indent for one paste in Spacemacs or, alternatively, is there a way to disable auto-indent on paste altogether (in that second case it'd be cool to have a command to indent the last pasted block).

  • 1
    any chance you are running your Emacs under a terminal emulator? Commented Jul 10, 2016 at 13:03
  • 1
    No, I'm running as a GUI app under OSX (sorry, I should have mentioned that) Commented Jul 10, 2016 at 16:08
  • 1
    He's speaking about evil's p command, not about pasting with the mouse.
    – jch
    Commented Jul 11, 2016 at 1:27

2 Answers 2


You can disable indent on paste altogether with:

(setq-default spacemacs-yank-indent-threshold 0)

This variable is the size of paste region that is "too large" to auto-indent. We set it to 0 so that every region is too large.

  • Only this work. But when I type C-i, it still indent with wrong tab width. Emacs indentation makes me crazy.
    – winner.ktw
    Commented Jun 28, 2022 at 9:23

Go to INSERT mode and then hit CTRL+U and then paste it with +V.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.