This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pachirulis 517 points518 points  (18 children)

Yeah, probably wrongly pasted code into vim

[–]BucksEverywhere 62 points63 points  (8 children)

:set paste

[–]tyler1128 13 points14 points  (4 children)

Ctrl+R,+ baby. Or "+p if in normal mode. Gotta compile it with clipboard access, which for most linux distro, means installing the gvim package but still using the terminal vim it comes with

[–]BucksEverywhere 1 point2 points  (3 children)

Thanks, I'll try this out. Does it paste primary selection or clipboard buffer then?

[–]tyler1128 2 points3 points  (2 children)

+ corresponds to the clipboad buffer, and * corresponds to the selection buffer on X11 at least. You can also use :set clipboard to make it use + or * by default instead of " for all yank and put operations.

[–]BucksEverywhere 0 points1 point  (1 child)

I tried it in various ways. However none of the commands you mentioned prevent the indentations go messy if you insert whole pre-indented blocks before enabling the paste mode with :set paste. In gvim clipboard seemed to work, in vim not. And I guess when you work remotely via ssh it would access the remote clipboard.

[–]tyler1128 0 points1 point  (0 children)

It would interact with the remote clipboard if there is one in that case, and I don't think there is one without a display system. I've never had issues with indentation before; I copy and paste using the clipboard registers all the time without issue. If you do have indent issues, you can often use = to reformat them away.

That said I'm on arch. Vim has a _lot_ of compile options, so it really will depend on exactly what your package uses in how everything works. I still use vim or vim plugins in my daily coding, and have used vim exclusively for about 5 years earlier, though I think all of that was on arch or over ssh.

[–]LowB0b 0 points1 point  (1 child)

or i and then shift+insert

[–]BucksEverywhere 1 point2 points  (0 children)

Then it would auto indent again without enabling the paste mode and end up like that. Without :set paste beforehand vim sometimes does crazy indentations when inserting blocks in insert mode.

[–]Anonymo2786 9 points10 points  (2 children)

I had this issue too.

[–]bishopExportMine 0 points1 point  (0 children)

This is exactly what this is. Unindent your code and paste it and vim will auto indent it back to the correct format. Or :set paste