Protip: Pasting code in Vim (Updated)

On Ruby Rogues a few weeks back, Ben Orenstein mentioned he tries to spend 15 minutes a day improving his workflow and tools. I decided to take this onboard and this week I looked into how to paste code in Vim without loosing its indentation.

1. Turn off autoindent.

  :set paste

2. Enter insert mode.

3. Paste code

4. Turn autoindent back on.

  :set nopaste

I found the solution here.

Enjoy
Alex

Written on February 9, 2014