Search code examples
urlcharacterwhitespaceremoving-whitespace

Is there any reason the lines of code get copied jointly from the URL?


I've tried to copy some code from an online book - Link here - into my Visual Studio Code, using Ctrl + C. In the book, the code appears in the format I desire to have within my editor:

salaries_and_tenures = [(83000, 8.7), (88000, 8.1), 
                        (48000, 0.7), (76000, 6),
                        (69000, 6.5), (76000, 7.5),
                        (60000, 2.5), (83000, 10),
                        (48000, 1.9), (63000, 4.2)]

However, if I copy it from the previously mentioned URL, the code looks like that in the editor:

salaries_and_tenures=[(83000,8.7),(88000,8.1),(48000,0.7),(76000,6),(69000,6.5),(76000,7.5),(60000,2.5),(83000,10),(48000,1.9),(63000,4.2)]

Also, if I download the file locally and I proceed with copying the code into my editor (from the PDF), the code looks alike the one in the book:

salaries_and_tenures = [(83000, 8.7), (88000, 8.1),
                        (48000, 0.7), (76000, 6),
                        (69000, 6.5), (76000, 7.5),
                        (60000, 2.5), (83000, 10),
                        (48000, 1.9), (63000, 4.2)] 

Does anyone know what is happening behind the scenes? Is there any reason the white-space characters get deleted? (Remark: it is crystal clear that it's not an editor-related issue, because I got the same issue here, when I wrote the post)


Solution

  • As you mentioned yes this is not editor related issue. As you know pdf files don't store data as plain text. so copy and pasting from them is not exactly like notepad, word, etc.

    But the question is why sometimes it removes white spaces and sometimes doesn't? This is because of your pdf reader. probably you use different pdf readers in the browser and your OS. some pdf readers let you copy white spaces and some don't.

    if you want to copy white spaces without downloading pdf just use your OS pdf reader for online reading too (There might be some option about online data source in your pdf reader).