3

Whenever I select a code sample from an answer on this site (or SO) and paste it into the SQL Server query editor, the newlines turn into spaces, and the resulting one-line query is very hard to read or re-format. I get the same results when pasting into notepad. Does anybody have any workarounds for this problem? (I am using IE8)

Here's the most recent sample codeblock that I experienced this with (this one's from SO, but it's the same thing here).

Update: Based on comments so far, I believe this is probably a limitation of IE8 and its use of the clipboard. Unfortunately I am prohibited by corporate policy form using any other browser. So perhaps I should migrate this question to SuperUser and ask if there are any workarounds for IE8's copy-function deficiencies. Still, I wonder if any IE8 users on this site can reproduce the problem.

14
  • What browser are you using? Can you provide a particular sample codeblock that's giving issues? Are you pasting directly into SSMS?
    – jcolebrand Mod
    May 23, 2012 at 17:40
  • Simple workaround is to try pasting into notepad, then recopying (I usually do this: {win+r}{n}{o}{enter}{ctrl+v}{ctrl+a}{ctrl+x}{alt+f4} mouse to window {ctrl+v})
    – jcolebrand Mod
    May 23, 2012 at 17:42
  • but notice that my run box often has notepad in the history, so "no" is sufficient to highlight notepad
    – jcolebrand Mod
    May 23, 2012 at 17:42
  • At random I just copied the first code block from (dba.stackexchange.com/questions/18327/…) into SSMS via Chrome (highlight + ctrl-c) and it pasted with all the linefeeds as apporpirate.
    – jcolebrand Mod
    May 23, 2012 at 17:43
  • Works perfectly for me too...
    – JNK
    May 23, 2012 at 17:51
  • @jcolebrand. Thanks for all your suggestions. As I mentioned in my updated post, I get the same results when pasting into Notepad, so I'm guessing this must be a browser thing.
    – kmote
    May 23, 2012 at 17:52
  • Since Chrome installs to userspace and not to Program Files, try installing Chrome, testing with that, and seeing what happens next.
    – jcolebrand Mod
    May 23, 2012 at 17:54
  • would if i could, but this is office workstation, and it's locked down. Oh well.
    – kmote
    May 23, 2012 at 17:57
  • @kmote Mine is locked down too but I can install chrome.
    – JNK
    May 23, 2012 at 18:00
  • @kmote I'll repeat myself. TRY INSTALLING CHROME. Really, you don't need privileges, you just download and install it. Now, if you've tried installing Chrome, and you can't, then that's different, but that's not what you've said here. You're telling us you haven't ever tried, because you just know it won't work, and we're telling you to try anyways, you'll be pleasantly surprised.
    – jcolebrand Mod
    May 23, 2012 at 21:00
  • It's not that I don't think it would work (I'm sure it would work splendidly), but it is against the corporate policy here. Thanks again anyways!
    – kmote
    May 23, 2012 at 22:20
  • This is a long standing issue. Get the impression from here that it is supposed to be fixed though May 24, 2012 at 9:08
  • Thanks for the link @Martin Smith. One would get that impression from Atwood's comment, but my experience testifies otherwise. I sure wish someone with IE8/9 could confirm my findings and upvote this post so that it might get some more attention.
    – kmote
    May 24, 2012 at 14:31
  • 1
    Great tip from @Martin Smith on the other link: WORKAROUND = click "Edit"
    – kmote
    May 24, 2012 at 14:33

1 Answer 1

2

i usually use chrome, but when i tried IE8 i got the same problem as yours

the code appears in one line ignoring all the line Carriage return.

i tried to copy the code snippet from the source and it worked fine.

IE8 View Source

This is a bug in IE8, ignoring the Carriage return & line feeds of the <pre> tag check out these links its an IE bug - and not in StackOverflow.

https://stackoverflow.com/questions/7707/ie8-overflowauto-with-max-height

https://stackoverflow.com/questions/451486/pre-tag-loses-line-breaks-when-setting-innerhtml-in-ie

http://www.quirksmode.org/css/whitespace.html

http://www.sitepoint.com/forums/showthread.php?618830-IE8-Bug-I-need-to-fix

the bug mentioned in Microsoft site https://connect.microsoft.com/IE/feedback/details/408759/ie-v8-0-overflow-scroll-causes-element-to-always-have-its-max-height

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .