We love Vim here at BLEN. Sure, we have a few developers who have moved on to Atom. But we politely encourage all our developers to try Vim first. Granted, the Vim learning curve is real. My initial experience with Vi/Vim is quite similar to the one described in the Slate article that recently resurfaced on Twitter, "The Oldest Rivalry in Computing". A decade later, the state of our union is stronger than ever!
There was one quirk that I never really figured out, though. Whenever I tried to copy and paste an indented code block, the resulting text was quite ugly. It seemed as though the indentation in the original text was being multiplied by my indentation settings in vimrc. So I would paste the text into gedit and save it to later :read
the file into the final text. I did that for a few years.
In May 2013, Mike and I were in Portland for DrupalCon. After attending a full day of sessions, we headed to a coffee shop in the city to work on the new ED.gov. Mike noticed that I was jumping through hoops to paste a text in Vim. He then said, "you know you can just type :set paste
, right?" I responded with, "what?" (fighting back tears). I could not believe there was such a simple solution to something that had been bugging me for years. I would like to think my productivity has gone way up eversince.
And, yesterday, I decided I would rather use a toggle than having to type :set paste
and :set nopaste
. I wanted to consult the Vim docs first, though. Here is what :help paste
returned:
I prefer to use F5
and F6
keys instead since I am on a Mac. Otherwise, I would have to use the fn
key.
If this suits you, add the following in your .vimrc
file:
{% highlight bash %} """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Paste " :help paste recommends F10 and F11, but this is hard on Mac keyboard. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" map :set paste map :set nopaste imap :set paste imap set pastetoggle= {% endhighlight %}