Vim: Pasting text as is in Vim in Paste Mode

Pasting code from another application to Vim is a nightmare. The autoindent features of Vim drive you crazy. How to make it easier to use?

asked Jan 21, 2013 by forum (2,150 points)

1 Answer

 
Best answer

Pasting code from another application to Vim is a nightmare. The autoindent features of Vim will drive you crazy. What help you out is the "paste mode".

To paste code as is:

:set paste

Past code to vim

:set nopaste

But typing so many characters is not convenient enough. We can turn auto indenting for pastes on and off with pastetoggle:

Add to ~/.vimrc:

set pastetoggle=<F2>

The to paste code (in insert mode, of course):

Press F2 (toggles the 'paste' option on).
Paste code.
Press F2 (toggles the 'paste' option off).

answered Jan 21, 2013 by anonymous
selected Jan 22, 2013 by SA

Please log in or register to answer this question.

Related questions

1 answer
asked May 25, 2014 by Eric Z Ma (44,280 points)
1 answer
asked Dec 14, 2013 by anonymous
1 answer
asked Feb 6, 2013 by anonymous
1 answer
1 answer
asked Jan 21, 2013 by forum (2,150 points)
Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...