vi / vim – extra indents when pasting text?

I can copy characters in other apps such as browsers with ctrlc.

I can then press i to enter insert mode in vim and press shiftctrlv to paste the text in.

The problem is that each line gets indented a bit more so I end up with:

enter image description here

but what I want (and end up manually editing to achieve) is:enter image description here

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Using :set paste prevents vim from re-tabbing my code and fixes the problem.
Also, :set nopaste turns it off

I also put set pastetoggle=<F2>in my .vimrc so I can toggle it with the F2 key.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply