When you want to paste in Vim, you want vim to not use indenting, because that messes up your code. I used to use :insert, but on some machines, it would still indent. I discovered the :set paste command, which works quite well.
Categories
Tags/Keywords
Recent Comments
- Rowan Rodrik on pg_safer_settings: dealing with PostgreSQL settings more … safely
- Rowan Rodrik on pg_role_fkey_trigger_functions: establishing and maintaining foreign key-like relationships to database ROLEs
- Rowan Rodrik on pg_mockable: inlineable mocking of PostgreSQL functions, like now(), or then()
Copyleft: These days everything you can think of is copyrighted, patented, protected or otherwise made into someone's imaginary intellectual property. I have a lot of imagination but not enough to pretend that I have some divine right to share things with you without giving you the right to share it further. That would be childish. So, everything here is licensed under a Creative Commons Attribution-Noncommercial-Share Alike license. That means that you can bloody well do anything you like with my content as long as you tell that it's from me (or the respective author). Only if you want to make money from my content do you have to ask me permission first. (As if I could be bothered to sue.) Oh, and you can't redistribute your derivative content under more restrictive terms. Share the love.
Colophon: This weblog is powered by a WordPress installation running on PHP5 and MySQL, hosted by NearlyFreeSpeech.Net's outstanding FreeBSD hosting platform. The markup for this WP theme is my own and should usually validate as some sort of XHTML concoction. So should the CSS. I've actually blogged about this theme.
I often use the following if :insert doesn’t give me the desired result:
I learned that trick from Kim Hendrikse a long time ago. It also works in ol’ vi.
While researching another post, I actually just used :set paste for the first time and was amazed by how well it works. I recommend anyone to try it. I especially like how every subsequent time that you change to insert mode, it will have this (clearly) enabled until it’s explicitly disabled again.
However, in that same post that I was working on, I also introduce the following solution, which uses the excellent XSel tool to do the same, with more flexibility and power (I think). Here’s an example with xsel that pastes the contents of PRIMARY:
Or, if you prefer the CLIPBOARD:
That’s how easy it is.
Hmm, my vim only has insert mode enabled once. If you go to command mode and then back to insert, it’s no longer paste mode. And that’s the way I prefer it.