4 ms·
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: som
by pavel_lishin 14y ago
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 }
- TallGuyShort 14y agoAnother tabs-only approach is to also add a single tab before some_key_1.
- DanBC 14y agoWatch 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 }
- JensenDied 14y agoUse 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, }
- mrkodiak 14y agoWhen 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.
- amcgregor 14y agoI 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? :)
- msutherl 14y agoWhat's wrong with the "I want to beat you with an oar" approach? This is what I do and it works great.