I wanted to paste some HTML into Vim, and I was having a hard time getting something that preserved existing indentation.

After doing :help autoindent, I found out about smartindent. So, I turned both smartindent and autoindent off before doing my paste. That worked wonders!

1 :set nosmartindent
2 :set noautoindent
3 i
4 <CMD>-V
5 <ESC>
6 :set smartindent
7 :set autoindent

VoilĂ , a correctly pasted, non-indented version of whatever was in the clipboard!

UPDATE: 2 minutes after I posted the link to this article on Twitter, @jpalardy replied: