3

Sometimes there are one or two lines of code which are overlength, like this

set10 = "UPDATE " + databasenow + " SET 1= '" + 1.ToString + "', 2= '" + 2.ToString + "', 3= '" + 4.ToString... and so on and so forth

in most cases I think it's better to have it at a glance instead of trying to scroll and reconstruct it in ones mind, thus I format it with backticks.

set10 = "UPDATE " + databasenow + " SET 1= '" + 1.ToString + "', 2= '" + 2.ToString + "', 3= '" + 4.ToString... and so on and so forth

However, such edits are reversed from time to time by other users, so:

How to deal with such code lines/snippets?

7
  • Ideally, you shouldn't have overlength one-liners in your code ;-) Mar 15, 2014 at 12:36
  • @jandvorak I never have. I never have code with overlength lines at all since the mousewheel's target is the vertical scrollbar mostly.
    – user247623
    Mar 15, 2014 at 13:02
  • 1
    That is VB.NET code. Arbitrarily breaking the line makes it invalid, so of course users will try to fix it. Post proper code. Mar 15, 2014 at 13:28
  • 1
    @Uphillluge & _ ftw. Mar 15, 2014 at 20:41
  • @uphillluge This is the revision that made me ask the question. I thought it is evident, that there is no "real" line break in the code
    – user247623
    Mar 16, 2014 at 12:01
  • Ugh, I'll never understand why SO users post a question and use a completely inappropriate code snippet when they can just as easily post the real code. Mar 16, 2014 at 12:11
  • @uphillluge It is not a completely inappropriate code snippet. I took it randomly cause the oneliners I encounter can be in any language. Actually that was part of the question, whether the backticks could be used to indicate that it is a single line and no line breaks were made..
    – user247623
    Mar 16, 2014 at 16:01

1 Answer 1

5

Backticks don't get syntax highlighting, they're really only meant for very short pieces of code inline in a sentence. For actual statements or blocks, always use proper code blocks.

Try to split long lines where it makes sense. Different people will have different styles of course, just like for regular coding styles, so what you select might not always get accepted.

In this case, try something like:

set10 = "UPDATE " + databasenow
      + " SET 1= '" + 1.ToString
        + "', 2= '" + 2.ToString
        + "', 3= '" + 4.ToString
        + // ad libitum

(Some languages might not support that, or require some syntax at the end of the line to indicate that it's a continuation - don't touch the code if you're not familiar with the language anyway.)

7
  • Almost... ;-)
    – Arjan
    Mar 15, 2014 at 16:28
  • (: Fixed @Arjan, but without a fixed-width font, there is no hope. :(
    – Mat
    Mar 15, 2014 at 16:38
  • 1
    Yeah, that fixed font is a Chrome-on-my-Samsung thing. Other browsers and Chrome-on-other-droids do have fixed fonts. (See Not enforcing fixed width font family.) Still then: no scrollbars on the mobile theme, but code is wrapped and always shown. Nick wrote: Two-finger scrolling doesn't work reliably (or at all) on some of the Android devices I've tested with. Makes wrapping the only real option."
    – Arjan
    Mar 15, 2014 at 16:48
  • That said, try again ;-)
    – Arjan
    Mar 15, 2014 at 16:57
  • An A for effort ;-) (And yeah, this is the small screen of a HTC Wildfire S, but I also have an Xperia S10 mini lying around somewhere, with an even smaller screen...)
    – Arjan
    Mar 15, 2014 at 17:24
  • 1
    I... surrender.
    – Mat
    Mar 15, 2014 at 17:42
  • :-) Just to be sure: I very much agree with your answer.
    – Arjan
    Mar 15, 2014 at 17:54

You must log in to answer this question.