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? – Yasushi Shoji Jul 10 '16 at 13:03
  • 1
    No, I'm running as a GUI app under OSX (sorry, I should have mentioned that) – Thomas Parslow Jul 10 '16 at 16:08
  • 1
    He's speaking about evil's p command, not about pasting with the mouse. – jch Jul 11 '16 at 1:27

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


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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