Aug 1, 2022

Format Code Settings in Arc

Arc v3.4 introduces a new feature enabling you to format your code. It makes it easier to apply your standard practices across your team.

 

Benefits of Code Formatting

But who cares about code formatting anyway? Humans, of course! You and me. We like to tell ourselves that we don’t mind writing ‘dirty’ code as long as it works. But when you eventually have to come back to your code in a few months, you will be very annoyed at the time and effort it takes just to read and understand what the code is doing.

The benefits of good code formatting are highly valuable:

  • It’s easier to read.

  • It’s faster to understand.

  • You can improve consistency across your team.

  • It makes your work look professional.

If your standard coding practices are different to the default, you can open the settings dropdown and turn on/off or update the rules as below:

Easily Apply Your Own Standards.

Arc comes with a set of predefined standards to get you started, but this feature is highly customizable to fit any standard practices that you want to implement. For example, if you prefer your functions in upper or lower case, you can easily update it in the formatter options:

This feature is also available in the Rules Editor:

Turn on/off format rules

To enable or disable a specific rule, just click the tick box on the left. You can also disable/enable all by clicking on the first box:

Reset all rules

To reset the options and go back to the default rules, just click the cross on the top right:

Sharing your rules (Import/Export)

The rules are stored in your web browser’s cache. If you want to share your rules with your team, you will need to use the import/export buttons on the top right corner:

  1. Click the export button on the top right corner.

  2. Send it to your colleagues.

  3. They will just need to click the import button and select the file.

Edit a rule

To edit a rule, just click the gear icon from the right. If you highlight the icon, it will show the description:

After clicking on the gear icon, it will open a pop-up to edit the rule:

Rules definition:

Please find below the list of all coding rules:

  • Change Keyword Case: Changes the case (upper, lower, camel, etc) of keywords.

  • Format Function Calls: Special formatting for function calls. Supports padding before and after function name, open parenthesis, commas and close parenthesis.

  • Format If Blocks: Format IF/ELSEIF/ELSE/ENDIF code blocks with indenting, line breaks & padding.

  • Format While Blocks: Add breaks and indent code between WHILE and END statements.

  • Add Breaks To Comment Blocks: Adds carriage returns to separate comments. Manual lines can be forced by starting a comment line with “##”.

  • Pad Symbols: Adds padding around specified symbols

  • New Line After Semicolon: Adds a carriage return at the end of a statement.

  • New Line After Comment Line: Adds a carriage return at the end of a comment line.

  • Limit Number of Line Breaks: Limit the number of consecutive line breaks implemented after all rules are run.

Related content

Loading related content