Pasting into Vim Messing Up Indentation
Published: April 15, 2020
This morning I was trying to paste so XML from a local file into a remote file using Vim. However when I did it, it was messing up the indentation really badly, essentially indenting each new line an additional level.
Some Googling brought me the article “How to stop auto indenting” on the Vim Tips Wiki. The article is thoroughly details the many different options to control Vim’s auto-indentation.
For me, the best option was “Disabling auto indent temporarily to paste” as I was in the middle of production maintenance and didn’t want to think about the best long term configuration.
With the file open while in normal mode enter the following command:
Now you can paste text without having the indentation method messed up: