ZelluX
ZelluX

Reputation: 72795

Any Emacs command like paste-mode in vim?

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

Answers (5)

4e6
4e6

Reputation: 10776

Prefixed yank command C-uC-y would yank without indentation. Works with Emacs 25.

Upvotes: 5

Matthijs Douze
Matthijs Douze

Reputation: 106

A quick workaround for Python is to paste into a """ ... """ block.

Upvotes: 5

Maresh
Maresh

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

mamboking
mamboking

Reputation: 4627

You could try

c-toggle-syntactic-indentation

Upvotes: 0

Jouni K. Seppänen
Jouni K. Seppänen

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

Related Questions