Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 476
ZelluX Avatar asked Jun 12 '09 13:06

ZelluX


People also ask

How do I paste properly in Vim?

When pasting text through a terminal emulator, the auto-indent feature may destroy the indentation of the pasted text. And if you want to paste as is from the clipboard. Just press F3 in insert mode, and paste. Press F3 again to exit from the paste mode.


2 Answers

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 ;-)

like image 56
Maresh Avatar answered Sep 21 '22 13:09

Maresh


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.

like image 45
Jouni K. Seppänen Avatar answered Sep 25 '22 13:09

Jouni K. Seppänen