Reputation: 72795
When i'm trying to paste some code from browser to Emacs, it will indent code automatically, is there any way to stop Emacs from indenting temporarily like :set paste in vim?
Upvotes: 29
Views: 8866
Reputation: 10776
Prefixed yank command C-uC-y would yank without indentation. Works with Emacs 25.
Upvotes: 5
Reputation: 106
A quick workaround for Python is to paste into a """ ... """
block.
Upvotes: 5
Reputation: 4712
The easiest way with emacs24 is:
M-x electric-indent-mode RET
That disables auto indentation.
Paste your thing.
renable
M-x electric-indent-mode RET
Or just M-x UP-Arrow
;-)
Upvotes: 39
Reputation: 44182
Switch into the *scratch*
buffer (or just to some nonexistent buffer; it will be in Fundamental mode, which shouldn't do any autoindentation unless you have somehow configured it to do so), type C-SPC
to start the region, paste your text, type C-w
to cut it within Emacs, switch back to your original buffer, type C-y
to paste.
Upvotes: 14