How exactly does the ‘paste’ mode in Vim work?

If you have ever used autoindent in Vim, it goes crazy if you paste code from elsewhere into vim in insert mode. So, "paste" mode temporarily turns off autoindent and you can have a good looking code even when you copy and paste from outside vim.

Try copying and pasting code from elsewhere into vim with autoindent on and paste mode off, you will see that vim keeps on indenting with each line. Every new line is indented, so if you paste a thousand lines, the thousandth line will have 1000 tabs in the beginning.

See question on Quora

I like to blog about various topics ranging from education in IITs to social issues in India and US. All opinions and views presented here are my own and not of my employer.

Leave a Reply