2

So let's say I have the following code:

if (true) {
    // do stuff
    // do additional stuff
}

I open up vim in PuTTY and right click to paste the above code into vim and it gets pasted like this:

if (true) {
        // do stuff
        //      // do additional stuff
        //      }

It's like it's auto-indenting every time a new line is encountered and the additional tabs just indent it that much further. And it also seems to be assuming that if the previous line was a comment that the next line will be one as well.

Even if I wasn't trying to copy / paste into vim it's not behavior I like but, the fact that I am makes the input barely usable.

Is there any way to disable this behavior?

Thanks!

4
  • 1
    Just to focus on the correct issue, the auto indenting is simply because of the commenting it. So the question is more like vim auto commenting out some pasted lines Commented Jun 14, 2023 at 17:04
  • 2
    Does the info in unix.stackexchange.com/questions/84639/… explain/address your question? Commented Jun 14, 2023 at 21:20
  • 3
    :set paste, or set nopaste to undo
    – Panki
    Commented Jun 14, 2023 at 21:22
  • The comment of @Panki should be the official answer. There is nothing too easy. Commented Aug 18, 2023 at 15:33

0

You must log in to answer this question.

Browse other questions tagged .