Menu

#16 Use TABs or four spaces for indentation in code

closed
Zangune
enhancement
Irrelevant
low
2025-06-10
2022-09-19
Zangune
No

Source code is indented with just one space, and it is not indented as it's standard almost everywhere: a line of code and the next line of code that depends on the previous one four spaces on the right (someone uses a tab instead of four spaces). In example

IF DEFINED ProgramFiles(x86) (
 SET WindowsNumberOfBits=64
) ELSE (
 SET WindowsNumberOfBits=32
)

should be (for code readability, at least)

IF DEFINED ProgramFiles(x86) (
    SET WindowsNumberOfBits=64
) ELSE (
    SET WindowsNumberOfBits=32
)

To fix this, we need a bit of attention, because we used some tricks, like the use of the caret (^), to break lines and keep line lenght below 80 characters (which is itself a good coding practice).

Related

Forum: Copy and paste from Code may not respect tabs and newlines

Discussion

  • Zangune

    Zangune - 2025-05-17
    • status: open --> pending
    • assigned_to: Zangune
     
  • Zangune

    Zangune - 2025-05-17

    I will test version [c:0.22] a bit before publishing. This release should fix this minor issue, but still I have to update ISSUES.txt in the compressed archive.

     

    Related

    Code: 0.22


    Last edit: Zangune 2025-05-20
  • Zangune

    Zangune - 2025-05-24
    • summary: Use multiples of four spaces for indentation in code --> Use TABs or four spaces for indentation in code
     

    Last edit: Zangune 2025-05-24
  • Zangune

    Zangune - 2025-05-24

    As I wrote

    we need a bit of attention, because we used some tricks, like the use of the caret (^), to break lines


    In particular, lines 115 and 116 of version 0.21 are

    DIR/B "%~dp0"^
        |FIND "preferences.ini">NUL
    

    and four spaces here will not work well, so I opted for using TABs.

     

    Last edit: Zangune 2025-05-24
  • Zangune

    Zangune - 2025-05-25
    • status: pending --> closed
     
  • Zangune

    Zangune - 2025-06-10

    On Simon Sheppard website, I read that

    Tab Completion is disabled by default, it has been known to create difficulty when using a batch script to process text files that contain TAB characters


    So this is a readability versus usability tradeoff.

     

    Last edit: Zangune 2025-06-10

Anonymous
Anonymous

Add attachments
Cancel