NormalizeSeparators

Normalize separators and indents.

NormalizeSeparators is included in the default transformers but it can be also run separately with:

robotidy --transform NormalizeSeparators src

All separators (pipes included) are converted to fixed length of 4 spaces (configurable via global option --spacecount). To separately configure the indentation, use --indent global option.

Note

There are transformers that also affect separator lengths - for example AlignSettingsSection. NormalizeSeparators is used as a base and then potentially overwritten by behaviours of other transformers. If you only want to have fixed separator lengths (without aligning) then only run this transformer without running the others.

*** Settings ***
Library  library.py  WITH NAME          alias

Force Tags           tag
...   tag

Documentation  doc
...      multi
...  line

*** Test Cases ***
Test case
  [Setup]  Keyword
   Keyword  with  arg
   ...  and  multi  lines
     [Teardown]          Keyword

Test case with structures
    FOR  ${variable}  IN  1  2
    Keyword
     IF  ${condition}
       Log  ${stuff}  console=True
  END
   END

Configure separator

By configuring a global option spacecount, you can change the default separator length:

robotidy --spacecount 8 src
*** Settings ***
Library  library.py  WITH NAME          alias

Force Tags           tag
...   tag

Indentation

By default, indentation is the same as spacecount value (default 4 spaces). To configure it, use --indent:

robotidy --indent 4 src

Combine it with spacecount to set whitespace separately for indent and separators:

robotidy --indent 4 --spacecount 2 src
*** Keywords ***
Keyword
  FOR     ${var}  IN RANGE     10
    Keyword With  ${var}
  END

Skip formatting

It is possible to use the following arguments to skip formatting of the code:

Documentation is formatted by default. To disable formatting the separators inside documentation, and to only format indentation, set skip_documentation to True:

robotidy --configure NormalizeSeparators:skip_documentation=True src
TEST_TC
    [Argument]    ${a}    ${long_arg}
    [Documentation]     Test Doc.
    ...
    ...    Arguments:
    ...    a:               Argument A
    ...    long_arg:        Argument long_arg.
   Test Case Body

Ignored sections

You can decide which sections should be transformed by configuring sections = comments,settings,variables,keywords,testcases param:

robotidy --configure NormalizeSeparators:section=variables src
*** Settings ***
Library  library.py  WITH NAME          alias

Force Tags           tag
...   tag

*** Variables ***
${var}  1  # only this section will be transformed

Supports global formatting params: --startline and --endline.