Skip to main content

vi/vim: how to paste correctly

As I read on this blogpost I am not the only one who has problems pasting code or text into vi editor.

“Instead of looking like you want it to, it takes every tab and just autoindents like crazy giving you a mess to clean up.” Yes, thats true. Just see the above mentioned blogpost.

The solution is easy:

Before pasting enter in vi

:set paste

Please notice the message
-- INSERT (paste) --

on the bottom of vi. Now you can paste your code or text into vi without having to clean the added indents.

After finished pasting just enter

:set nopaste


Leave a Reply

Your email address will not be published. Required fields are marked *