Disable auto indent feature when pasting text in vim

This bugged me for some time before I finally looked for the solution. Turns out it was pretty simple.

Before pasting the text, do the following

set :paste

Once you have pasted your text

set :nopaste

I know this can get inconvenient if you do a lot of copy pasting (which probably you shouldn’t). This is when you can assign a function key to toggle the paste function

set pastetoggle=<F2>

Now just use Fn F2 before pasting and again once you are done.


Happy Viming!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s