While pasting something into a file opened in vim editor, sometime you will see kind of a "staircase" effect where each line is progressively spaced farther outward.
I was doing to copy paste the following lines into a file opened in vim
And it appeared like this
This happens because Vim assumes that I am actually typing and not pasting, so it indents the lines again (I already had autoindent set in my .vimrc), and this results in additional white spaces at front.
To avoid this, I ran the following command in vim command mode (before pasting)
Then pressed 'i' to switch to insert mode; pasted the lines. Worked!!
One may disable this by using:
Put Vim in Paste mode. This is useful if you want to cut or copy some text from one window and paste it in Vim. This will avoid unexpected effects. Setting this option is useful when using Vim in a terminal, where Vim cannot distinguish between typed text and pasted text.
This can also be achieved by setting:
i.e. set 'no auto-indent'. And 'auto-indent' can be set by
You might also like:
- Using tabs in vim editor, a small tutorial