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.
You can quickly try out these style options in your browser using the Codee Format Playground.
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-formatfrom parent directories. If no such file is found falls back toCodee.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}".
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 areOneItemPerLine,Regular.FirstLineFit: Set the preference for how the first line is used when breaking module imports into separate lines. Possible values areFitIfPossible,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).FirstOccurrence-> Take the casing of each identifier from its first occurrence in the file (only valid forIdentifiers).Preserve-> 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
! FirstOccurrence (before):
function Foo()
real :: myVar
myvar = 3.14
end function foo
! FirstOccurrence (after):
function Foo()
real :: myVar
myVar = 3.14
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: 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 for ModuleContains are:
IndentBeforeAndAfter-> 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.
Possible valures for Comments are:
Indent-> Always indent comments.DoNotIndent-> Do not indent comments and leave them as they are.IndentIfAlreadyIndented-> Indent comments if they are already indented.
Nested configuration flags:
ModuleContains: Set the indentation before and after thecontainsstatement 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
Comments: Set the indentation of comments.
! Indent:
module m
! This is an integer
integer :: i
! This is a real
real :: j
end module m
! DoNotIndent:
module m
! This is an integer
integer :: i
! This is a real
real :: j
end module m
! IndentIfAlreadyIndented:
module m
! This is an integer
integer :: i
! This is a real
real :: j
end module m
FixedFormLabelAlignment (FixedFormLabelAlignmentStyle)
Set the alignment used for the statement labels when in fixed-form compatible mode. Possible values are:
Right-> 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-> 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-> 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 theendkeyword.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-> 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-> Keep the original form as it is.
Nested configuration flags:
EndAssociate: Setendassociateorend associate.
! Joined:
associate v => myreal
endassociate
! Separated:
associate v => myreal
end associate
EndBlockConstruct: Setendblockorend block.
! Joined:
block
endblock
! Separated:
block
end block
EndBlockData: Setendblockdataorend block data.
! Joined:
block data
endendblockdata
! Separated
block data
end block data
EndCritical: Setendcriticalorend critical.
! Joined:
critical
endcritical
! Separated:
critical
end critical
EndTeam: Setendteamorend team.
! Joined:
change team (t)
endteam
! Separated:
change team (t)
end team
EndDoLoop: Setenddoorend do.
! Joined:
do i=0,n
enddo
! Separated:
do i=0,n
end do
EndEnum: Setendenumorend enum.
! Joined:
enum
enumerator :: on, off
endenum
! Separated:
enum
enumerator :: on, off
end enum
EndEnumerationType: Setendenumerationtypeorend enumeration type.
! Joined:
enumeration type
enumerator :: on, off
endenumerationtype
! Separated
enumeration type
enumerator :: on, off
end enumeration type
EndForall: Setendforallorend forall.
! Joined:
forall(i = 3:n)
c(i) = 0
endforall
! Separated:
forall(i = 3:n)
c(i) = 0
end forall
EndFunction: Setendfunctionorend function.
! Joined:
function foo()
endfunction foo
! Separated:
function foo()
end function foo()
EndIf: Setendiforend if.
! Joined:
if (i == 0) then
endif
! Separated:
if (i == 0) then
end if
EndInterface: Setendinterfaceorend interface.
! Joined:
interface i
endinterface i
! Separated:
interface i
end interface i
EndModule: Setendmoduleorend module.
! Joined:
module m
endmodule m
! Separated:
module m
end module m
EndModuleProcedure: Setendprocedureorend procedure.
! Joined:
module procedure p
endprocedure p
! Separated:
module procedure p
end procedure p
EndProgram: Setendprogramorend program.
! Joined:
program myapp
endprogram myapp
! Separated:
program myapp
end program myapp
EndSelect: Setendselectorend select.
! Joined:
select case (k)
end select
! Separated:
select case (k)
end select
EndSubmodule: Setendsubmoduleorend submodule.
! Joined:
submodule
endsubmodule
! Separated:
submodule
end submodule
EndSubroutine: Setendsubroutineorend subroutine.
! Joined:
subroutine foo()
endsubroutine foo
! Separated:
subroutine foo()
end subroutine foo()
EndType: Setendtypeorend type.
! Joined:
type myType
integer :: x
endtype
! Separated:
type integer :: x
end type
EndWhere: Setendwhereorend 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.
- Positive integer number (Default:
! 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. OverridesMaxToKeep. Valid values are:- Positive integer number (Default:
1). - Preserve: Keep consecutive empty lines as found.
- Positive integer number (Default:
! 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: Iftrue, 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: Iftrue, 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 addkind=(e.g.,real(kind=4) :: var).RemoveAlways-> Always removekind=(e.g.,real(4) :: var).Preserve-> 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-> 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+ corb+c).Leading-> Add leading space and keep the original trailing space (e.g.,b + corb +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 +corb + c).Trailing-> Add trailing space and keep the original leading space (e.g.,b + corb+ c).OnlyTrailing-> Add trailing space and remove the leading space (e.g.,b+ c).Preserve-> 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:
| OperatorClass | Example |
|---|---|
LeftParenthesisExpression | a / ( b + c) |
RightParenthesisExpression | (a + b ) / c |
LeftParenthesisGeneric | function ( a) |
RightParenthesisGeneric | function(a ) result(b)* |
LeftParenthesisKeyword | do while ( a > 0) |
RightParenthesisKeyword | if (a ) then |
Assignment | a = b |
Association | a => b |
ControlFlowAssignment | do i = 1, 5 |
KeywordAssignment | kind = 4 |
ParameterAssignment | parameter (PI = 3.141593) |
BinaryArithmetic | a + b |
Exponentiation | a ** b |
DefinedBinary | a .defbinop. b |
DefinedUnary | .defunop. a |
Relational | a < b |
RelationalLegacy | a .lt. b |
LogicalBinary | a .and. b |
LogicalNot | .not.` a |
UnaryPlusMinus | .not.` a |
Comma | a , b |
Concat | a // b |
DoubleColon | a :: 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