Skip to main content

Style Options

This section lists the supported style options. Value type is specified for each option. For enumeration types possible values are specified. In case an option or value is not specified a default value (here indicated in bold) is applied.

Tip

You can quickly try out these style options in your browser using the Codee Format Playground

Tip

You can use codee format --dump-config to dump the current effective configuration. Add --with-docs for inline documentation in the dump.

BasedOnStyle (String)

The style used for all options not specifically set in the configuration. Possible values are:

  • Codee -> A style recommended by Codee
  • InheritParentConfig -> Use the .codee-format from parent directories. If no such file is found falls back to Codee.
  • Preserve -> Preserve the original source code style. It can be used as a base configuration to create a specific style.

With this option you can overwrite some parts of your main style for your subdirectories. This is also possible through the command line, e.g.: --style "{BasedOnStyle: InheritParentConfig, ColumnLimit: 20}"

Tip

You can use codee format --dump-preset-config <preset> to inspect a preset. Add --with-docs for inline documentation in the dump.

AlignAmpersandToColumnLimit (Boolean)

If true, free-form end-of-line continuation ampersands are always placed at the column limit instead of right after the end of the line. This option doesn't have any effect when there is no ColumnLimit set. Defaults to false.

With 40 as the column limit:

! true:
res = long_variable_name &
+ longer_variable_name
! false:
res = long_variable_name &
+ longer_variable_name

AlignAssignmentOperators (Boolean)

When breaking lines according to ColumnLimit, preferentially break at operators inside assignments. Possible values are: true or false. Defaults to false.

! true:
res = old &
* foo(3, 4)
! false:
res = old * foo(3&
, 4)

AlignUseItems (AlignUseItemsStyle)

Set the kind of alignment used when breaking module imports into separate lines.

Nested configuration flags:

  • Kind: Set the kind of alignment used when breaking module imports into separate lines. Possible values are OneItemPerLine [Default], Regular
  • FirstLineFit: Set the preference for how the first line is used when breaking module imports into separate lines. Possible values are FitIfPossible [Default], AlwaysBreak
! Kind: Regular, FirstLineFit: FitIfPossible
subroutine t()
use ModuleWithAVeryLargeName, only: function_one, &
function_two, function_three
end subroutine t

! Kind: Regular, FirstLineFit: AlwaysBreak
subroutine t()
use ModuleWithAVeryLargeName, only: &
function_one, function_two, function_three
end subroutine t

! Kind: OneItemPerLine, FirstLineFit: FitIfPossible
subroutine t()
use ModuleWithAVeryLargeName, only: function_one, &
function_two, &
function_three
end subroutine t

! Kind: OneItemPerLine, FirstLineFit: AlwaysBreak
subroutine t()
use ModuleWithAVeryLargeName, only: &
function_one, &
function_two, &
function_three
end subroutine t

BreakBeforeBinaryOperators (Boolean)

When aligning operators inside assignments, place them at the beginning of the line. Possible values are: true or false. Defaults to true.

! true:
res = old
* foo(3, 4)
! false:
res = old *
foo(3, 4)

Casing (CasingStyle)

Control the letter casing. Possible values are:

  • Lowercase -> All lowercase (e.g., real, integer, do)
  • Uppercase -> All uppercase (e.g., REAL, INTEGER, DO)
  • Capitalized -> First letter uppercase (e.g., Real, Integer, Do)
  • Preserve -> [Default] Keep the original casing as it is

Nested configuration flags:

  • Identifiers: Set the casing of variable and function names
! Lowercase:
function foo()
real :: var
end function foo

! Uppercase:
function FOO()
real :: VAR
end function FOO

! Capitalized:
function Foo()
real :: Var
end function Foo
  • Keywords: Set the casing of Fortran keywords
! Lowercase:
function foo()
real :: var
end function foo

! Uppercase:
FUNCTION foo()
REAL :: var
END FUNCTION foo

! Capitalized:
Function foo()
Real :: var
End Function foo
  • LogicalConstants: Set the casing of logical constants
! LowerCase:
.true.
.false.

! Uppercase:
.TRUE.
.FALSE.

! Capitalized:
.True.
.False.
  • LogicalOperators: Set the casing of logical operators
! Lowercase:
.and.
.or.

! Uppercase:
.AND.
.OR.

! Capitalized:
.And.
.Or.
  • RelationalOperators: Set the casing of relational operators
! Lowercase:
.lt.
.eq.

! Uppercase:
.LT.
.EQ.

! Capitalized:
.Lt.
.Eq.
  • UserDefinedOperators: Set the casing of user defined operators
! Lowercase:
.useroperator.

! Uppercase:
.USEROPERATOR.

! Capitalized:
.Useroperator.

ColumnLimit (unsigned)

Set the line size, breaking lines longer than the specified limit. Default value is 0, meaning no limit.

! Column Limit 0:
subroutine foo()
result = operand1 + operand2 * operand3 * (operand4 - operand5) + operand6

print *, "Very very very very very very very very very very very very long line"
end subroutine foo

! Column Limit 72:
subroutine foo()
result = operand1 + operand2 * operand3 * (operand4 - operand5) + &
operand6

print *, "Very very very very very very very very very very very" // &
" very long line"
end subroutine foo

CommentDirectivePrefixes (List of Strings)

List of comment prefixes, i.e., text following the comment marker (!), that should be interpreted as directives, which may be needed for proper line breaking and continuation. For example, the $omp and $acc directives are already supported by default. Defaults to an empty list: []

#define USER_OMP $omp

!USER_OMP parallel do private(i) reduction(+:sum)
do i = 1, 10
! loop body
end do

With CommentDirectivePrefixes: ["USER_OMP"] becomes:

#define USER_OMP $omp

!USER_OMP parallel do private(i) &
!USER_OMP reduction(+:sum) ! Ok: Valid directive continuation
do i = 1, 10
! loop body
end do

DisabledDirectivePrefixes (List of Strings)

List of comment directive prefixes, i.e., text following the comment marker (!), that will disable line breaks for the entire comment. Defaults to an empty list: []. Related: CommentDirectivePrefixes

#define USER_OMP_PARALLEL_DO $omp parallel do
!USER_OMP_PARALLEL_DO parallel do private(i) reduction(+: sum) ! Line isn't broken
do i = 1, 10
! loop body
end do

With DisabledDirectivePrefixes: ["USER_OMP_PARALLEL_DO"] the line isn't broken as it would make the directive invalid.

IndentSize (unsigned)

Set the number of columns to use for indentation. Possible values are:

  • unsigned integer
  • Preserve: [Default] Keep the original indent as it is
! IndentSize: 2
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function

! IndentSize: 8
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function

IndentExceptions (IndentExceptionsStyle)

Control specific indentation cases. Possible values are:

  • IndentBeforeAndAfter-> [Default] Increase the level of indentation before and after it
  • IndentBefore -> Increase the level of indentation before it only
  • DoNotIndent -> Keep the current indentation level after it

Nested configuration flags:

  • ModuleContains: Set the indentation before and after the contains statement in a module
! IndentBeforeAndAfter:
module m
integer :: i
contains
function foo()
print *, i
end function foo
end module m

! IndentBefore:
module m
integer :: i
contains
function foo()
print *, i
end function foo
end module m

! DoNotIndent:
module m
integer :: i
contains
function foo()
print *, i
end function foo
end module m

FixedFormLabelAlignment (FixedFormLabelAlignmentStyle)

Set the alignment used for the statement labels when in fixed-form compatible mode. Possible values are:

  • Right-> [Default] Aligns to the right (e.g., 10 print *, "Hi")
  • Left -> Aligns to the left (e.g., 10 print *, "Hi")
  • Preserve -> Do not align statement labels

ContinuationIndentSize (unsigned)

Set the number of spaces for line continuations or DoubleIndentSize ('IndentSize * 2'.)

! ContinuationIndentSize: 0
subroutine foo()
integer :: &
bar
end

! ContinuationIndentSize: 4
subroutine foo()
integer :: &
bar
end

DoubleColonSeparator (DoubleColonSeparatorStyle)

Separate the variable name from its declaration with '::'. Possible values are:

  • AddAlways -> Always add '::' to separate the type from the variable name
  • Preserve-> [Default] Keep the original separation as it is
! AddAlways:
real(kind=4), intent(in) :: x, y(:)
real(kind=8) :: z
integer :: a, b
character :: c

! Preserve:
real(kind=4), intent(in) :: x, y(:)
real(kind=8) z
integer :: a, b
character c

EndOfLineNormalization (EndOfLineNormalizationStyle)

Normalize end of line control character sequence. Possible values are:

  • Autodetect-> [Default] Use the first detected EOL in the input
  • Preserve -> Do not normalize end of line character sequences
  • Unix -> Use '\n'
  • Windows -> Use '\r\n'
! Autodetect:
! Before:
subroutine foo()\n
end subroutine\r\n

! After:
subroutine foo()\n
end subroutine\n

! Unix:
! Before:
subroutine foo()\n
end subroutine\r\n

! After:
subroutine foo()\n
end subroutine\n

! Windows:
! Before:
subroutine foo()\n
end subroutine\r\n

! After:
subroutine foo()\r\n
end subroutine\r\n

EndStatementFormat (EndStatementFormatStyle)

Set the format to write the 'end' keyword with its corresponding structure and name (e.g., end function foo. Possible values are:

  • EndOnly -> Set only the 'end' keyword
  • EndAndStructure -> Set the end with the corresponding structure kind (e.g., end function).
  • EndStructureAndName -> Set the end with the corresponding structure kind and its name (e.g., end function foo)
  • Preserve -> [Default] Keep the original form as it is.
! EndOnly:
module m
contains
function foo()
end
subroutine bar()
end
end

! EndAndStructure:
module m
contains
function foo()
end function
subroutine bar()
end subroutine
end module

! EndStructureAndName:
module m
contains
function foo()
end function foo
subroutine bar()
end subroutine bar
end module m

EndStatementSeparation (EndStatementSeparationStyle)

Set the separation between the 'end' and its corresponding statement (e.g., enddo end do). Possible values are:

  • Joined -> Prefer the joined form (e.g., enddo, endif)
  • Separated -> Prefer the separated form (e.g., end do, end if)
  • Preserve-> [Default] Keep the original form as it is

Nested configuration flags:

  • EndAssociate: Set endassociate or end associate
! Joined:
associate v => myreal
endassociate

! Separated:
associate v => myreal
end associate
  • EndBlockConstruct: Set endblock or end block
! Joined:
block
endblock

! Separated:
block
end block
  • EndBlockData: Set endblockdata or end block data
! Joined:
block data
endendblockdata

! Separated
block data
end block data
  • EndCritical: Set endcritical or end critical
! Joined:
critical
endcritical

! Separated:
critical
end critical
  • EndTeam: Set endteam or end team
! Joined:
change team (t)
endteam

! Separated:
change team (t)
end team
  • EndDoLoop: Set enddo or end do
! Joined:
do i=0,n
enddo

! Separated:
do i=0,n
end do
  • EndEnum: Set endenum or end enum
! Joined:
enum
enumerator :: on, off
endenum

! Separated:
enum
enumerator :: on, off
end enum
  • EndEnumerationType: Set endenumerationtype or end enumeration type
! Joined:
enumeration type
enumerator :: on, off
endenumerationtype

! Separated
enumeration type
enumerator :: on, off
end enumeration type
  • EndForall: Set endforall or end forall
! Joined:
forall(i = 3:n)
c(i) = 0
endforall

! Separated:
forall(i = 3:n)
c(i) = 0
end forall
  • EndFunction: Set endfunction or end function
! Joined:
function foo()
endfunction foo

! Separated:
function foo()
end function foo()
  • EndIf: Set endif or end if
! Joined:
if (i == 0) then
endif

! Separated:
if (i == 0) then
end if
  • EndInterface: Set endinterface or end interface
! Joined:
interface i
endinterface i

! Separated:
interface i
end interface i
  • EndModule: Set endmodule or end module
! Joined:
module m
endmodule m

! Separated:
module m
end module m
  • EndModuleProcedure: Set endprocedure or end procedure
! Joined:
module procedure p
endprocedure p

! Separated:
module procedure p
end procedure p
  • EndProgram: Set endprogram or end program
! Joined:
program myapp
endprogram myapp

! Separated:
program myapp
end program myapp
  • EndSelect: Set endselect or end select
! Joined:
select case (k)
end select

! Separated:
select case (k)
end select
  • EndSubmodule: Set endsubmodule or end submodule
! Joined:
submodule
endsubmodule

! Separated:
submodule
end submodule
  • EndSubroutine: Set endsubroutine or end subroutine
! Joined:
subroutine foo()
endsubroutine foo

! Separated:
subroutine foo()
end subroutine foo()
  • EndType: Set endtype or end type
! Joined:
type myType
integer :: x
endtype

! Separated:
type integer :: x
end type
  • EndWhere: Set endwhere or end where
! Joined:
where(i < 1.0)
endwhere

! Separated:
where(i < 1.0)
end where

EnsureNewlineAtEOF (Boolean)

Add a newline sequence at the end of the file if missing (Default: true)

! true:
1 program p
2 end program p
3

ConsecutiveEmptyLines (unsigned)

Number of consecutive empty lines. Valid values are:

  • Positive integer number
  • Preserve: Keep consecutive empty lines as found

Ensures that at most MaxToKeep consecutive empty lines appear in the file, by trimming longer sequences down to that value. BetweenProcedures overrides it for the lines that separate procedures, where it will also add empty lines to maintain that exact number.

Nested configuration flags:

  • MaxToKeep: Maximum number of consecutive empty lines to keep. Valid values are:
    • Positive integer number (Default: 1)
    • Preserve: Keep consecutive empty lines as found
! MaxToKeep: 1
! Before:
subroutine foo()
a = 0


end subroutine foo

! After:
subroutine foo()
a = 0

end subroutine foo
  • BetweenProcedures: Number of consecutive empty lines between procedures. Overrides MaxToKeep. Valid values are:
    • Positive integer number (Default: 1)
    • Preserve: Keep consecutive empty lines as found
! BetweenProcedures: 1
! Before:
subroutine foo()
end subroutine foo
subroutine bar()
end subroutine bar

! After:
subroutine foo()
end subroutine foo

subroutine bar()
end subroutine bar
  • RemoveAtStartOfFile: If true, removes all empty lines in the begining of the file (Default: true)
! true:
! Before:
1
2
3 subroutine foo()
4 end subroutine foo()

! After:
1 subroutine foo()
2 end subroutine foo()
  • RemoveAtEndOfFile: If true, removes all empty lines at the end of the file
! true:
! Before:
1 subroutine foo()
2 end subroutine foo()
3
4

! After:
1 subroutine foo()
2 end subroutine foo()

KindKeywordPrefix (KindKeywordPrefixStyle)

Add or remove the optional kind= keyword for intrinsic type variable declarations that already specify it. Possible values are:

  • AddAlways -> Always add kind= (e.g., real(kind=4) :: var)
  • RemoveAlways -> Always remove kind= (e.g., real(4) :: var)
  • Preserve -> [Default] Keep the original form as it is
! AddAlways:
real(kind=4) :: i
real(kind=dp) :: d

! RemoveAlways:
real(4) :: i
real(dp) :: d

MacroIdentifiers (List of Strings)

List of identifiers that should be interpreted as macros, which may be needed for correct parsing and re-casing. Defaults to an empty list: []

#define TEN 10

subroutine foo()
VAR = TEN
end subroutine foo

With MacroIdentifiers: ["TEN"] and casing set to lowercase, TEN remains as is:

#define TEN 10

subroutine foo()
var = TEN ! Macros are case-sentitive
end subroutine foo

RelationalOperators (RelationalOperatorsStyle)

Replace legacy textual relational operators (e.g., .lt., .eq.) by its symbol form. Possible values are:

  • UseSymbols -> Convert the legacy textual way into the corresponding symbol (e.g., .eq. is converted into ==)
  • Preserve-> [Default] Keep the original form as it is
! UseSymbols:
i < 10
i == 10

! vs

i .lt. 10
i .eq. 10

SpacesAroundOperators (OperatorSpacingStyle)

Control the spacing around the operators (e.g., a+b, a + b, a + (b*c)) Possible values are:

  • NoSpaces -> Remove all spacing around the operator (e.g., b+c)
  • Both -> Add leading and trailing space (e.g., b + c)
  • NoLeading -> Remove leading space and keep the original trailing space (e.g., b+ c or b+c)
  • Leading -> Add leading space and keep the original trailing space (e.g., b + c or b +c)
  • OnlyLeading -> Add leading space and remove the trailing space e.g., b +c)
  • NoTrailing -> Remove trailing space and keep the original leading space (e.g., b +c or b + c)
  • Trailing -> Add trailing space and keep the original leading space (e.g., b + c or b+ c)
  • OnlyTrailing-> Add trailing space and remove the leading space (e.g., b+ c)
  • Preserve-> [Default] Keep the original form as it is

These values can be applied to + and other operators with the following nested configuration flags. Examples are shown with Both spaces and the relevant operator in this format:

OperatorClassExample
LeftParenthesisExpressiona / ( b + c)
RightParenthesisExpression(a + b ) / c
LeftParenthesisGenericfunction ( a)
RightParenthesisGenericfunction(a ) result(b)*
LeftParenthesisKeyworddo while ( a > 0)
RightParenthesisKeywordif (a ) then
Assignmenta = b
Associationa => b
ControlFlowAssignmentdo i = 1, 5
KeywordAssignmentkind = 4
ParameterAssignmentparameter (PI = 3.141593)
BinaryArithmetica + b
Exponentiationa ** b
DefinedBinarya .defbinop. b
DefinedUnary.defunop. a
Relationala < b
RelationalLegacya .lt. b
LogicalBinarya .and. b
LogicalNot.not.` a
UnaryPlusMinus.not.` a
Commaa , b
Concata // b
DoubleColona :: b

RemoveConsecutiveWhitespace (Boolean)

Turn any sequence of whitespace characters between visible characters of a line into a single space, except within string literals and comments. Possible values are: true or false. Defaults to true.

answer = 'forty   two'   ! precomputed   answer

becomes

answer = 'forty   two' ! precomputed   answer

RemoveSemicolons (Boolean)

Remove semicolons when possible. Possible values are true or false. Defaults to true.

! true:
a = 5

! false:
a = 5;

RemoveTrailingWhitespace (Boolean)

Remove trailing whitespace (any tabs and spaces between the last visible character and the end of each line). Possible values are: true or false. Defaults to true.

If true, any tabs and spaces between the last visible character and the end of each line are removed.

! true:
function foo()
real :: x
! ^--- end of line
end function foo

! false:
function foo()
real :: x
! ^--- end of line
end foo

SeparateMultipleInlineStatements (Boolean)

Separate statements that are in the same line, delimited with a ';', into different lines. Possible values are: true or false. Defaults to true.

See RemoveSemicolons if you also want to remove the separating semicolons.

! true:
a = 5;
b = 6

! false:
a = 5; b = 6