News for hackers. Stuff that matters.
Re:Your code style guide is crap, but still better than noth... by pavel_lishin on Friday January 11, 2013 @12:21PM (#5043692)
I'm a convert to spaces after someone pointed out that it's easier to make your code 'pretty'.

    // This doesn't look very nice
    thing = { some_key_1: some_var_1,
    [->][->][->]some_key_2: some_var_2,
    [->][->][->]some_key_3: some_var_3 }
    
    // Neither does this.
    thing = { some_key_1: some_var_1,
    [->][->]some_key_2: some_var_2,
    [->][->]some_key_3: some_var_3 }
    
    // Feels good, man.
    thing = { some_key_1: some_var_1,
              some_key_2: some_var_2,
              some_key_3: some_var_3 }
    
    // I want to beat you with an oar.
    thing = { some_key_1: some_var_1,
    [->][->]  some_key_2: some_var_2,
    [->][->]  some_key_3: some_var_3 }
Re:Your code style guide is crap, but still better than noth... by JensenDied on Friday January 11, 2013 @12:30PM (#5043761)
Use tabs to align stuff on the left. This means putting some_key_1 on the next line. Also move the closing brace to a new line and add a comma after some_var_3.

Added advantage that you can move all of the lines around, :sort them or comment out individual ones without breaking anything.

Use spaces to align anything after the key, I usually align them with a tab stop so that several blocks line up.

  thing = {
  [->]some_key_1: some_var_1,
  [->]some_key_2: some_var_2,
  [->]some_key_3: some_var_3,
  }
Re:Your code style guide is crap, but still better than noth... by amcgregor on Friday January 11, 2013 @04:46PM (#5045246)
I use an alternate form that doesn't require alignment to an arbitrary column and works with tab indentation without needing to mix:

  thing = {
  [→][→]some_key_1: some_var_1,
  [→][→]some_key_2: some_var_2,
  [→][→]some_key_3: some_var_3,
  [→]}
Several benefits: easier to insert lines at the head or tail without making the SCM diff ugly, also avoids merge conflicts in those cases, and I use indentation of two levels to separate it from code.

Why suffer a problem when it's easily avoided? :)

Re:Your code style guide is crap, but still better than noth... by DanBC on Friday January 11, 2013 @12:24PM (#5043722)
Watch out or you'll get

    // I want to beat you with an oar.
    thing = {[->]some_key_1: some_var_1,
    [->][->][- >]some_key_2: some_var_2,
    [->][->][- >]some_key_3: some_var_3 }
Re:Your code style guide is crap, but still better than noth... by TallGuyShort on Friday January 11, 2013 @12:24PM (#5043719)
Another tabs-only approach is to also add a single tab before some_key_1.
Re:Your code style guide is crap, but still better than noth... by mrkodiak on Friday January 11, 2013 @01:11PM (#5044042)
When working on code bases that follow this style, there tends to be extra whitespace turn when new code is added to re-align everything back up.
Re:Your code style guide is crap, but still better than noth... by msutherl on Saturday January 12, 2013 @08:44PM (#5049639)
What's wrong with the "I want to beat you with an oar" approach? This is what I do and it works great.