Home > vim > vim-bracketed-paste


Auto indent in vim was killing me! Every time I wanted to copy and paste some code into vim, it would auto indent the already indented code. So things were looking messy. A fix was to do “:set paste” before pasting code. Adding “set paste” to my .vimrc did not help cause for some reason code was getting auto indented when I pasted, so I had to “set nopaste”, then “set paste” to get it to ignore indentation.

Installing vim-bracketed-paste worked for me.

From http://cirw.in/blog/bracketed-paste


Vim also handles newlines specially. When I am manually typing out code, vim will add extra space characters each time I hit return so that the resulting indentation is correct. Unfortunately when pasting into vim these extra spaces end up making a mess because the content I’m pasting already includes the correct indentation.

The usual work around for this is to manually run “:set paste” inside vim before pasting, but I often forget. The vim-bracketed-paste plugin uses code from Chis Page to do this automatically for me, so the content I paste into vim does not get automatically indented but the lines I type manually still do. You can install this plugin using pathogen, or by copy-pasting the code into your ~/.vimrc.


Categories: vim Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: