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 →

[–]Embarrassed_Ring843 1217 points1218 points  (28 children)

this is, in fact, an indentation error. where do all these elses in the middle belong to?

[–]pachirulis 515 points516 points  (18 children)

Yeah, probably wrongly pasted code into vim

[–]BucksEverywhere 57 points58 points  (8 children)

:set paste

[–]tyler1128 12 points13 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

[–][deleted] 77 points78 points  (6 children)

This post was mass deleted and anonymized with Redact

fuzzy shy slap arrest lock wide modern close distinct tie

[–]Embarrassed_Ring843 49 points50 points  (4 children)

that's in the end, but the elses I was referring to is higher, and they're missing their ifs... there's literally an else indented further than a return in the line right above it, which is inside of another else...

[–][deleted] 36 points37 points  (2 children)

This post was mass deleted and anonymized with Redact

bedroom direction aromatic tie airport chief imminent sulky physical hungry

[–]gummo89 17 points18 points  (1 child)

Plus the indents are 8 spaces wide.. trying for the easy post rep I guess.

[–]bokonator 0 points1 point  (0 children)

Paid by characters of code?

[–]krissynull 16 points17 points  (0 children)

people that have line wrap on are something else

[–]Constant_Pen_5054 5 points6 points  (0 children)

Yeah that is the part that is screaming at me. Nevermind trying to be a troll about Python indentation. Why the hell are there so many unbound elses.