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
BasedOnStyle (String
)
The style used for all options not specifically set in the configuration. This
option is supported within --style "{...}"
, the .codee-format
file or the
user specific config file.
Possible values are:
Codee
: A style recommended by Codee.Preserve
: Preserving the original source code style. It can be used as a base configuration to create a specific style.InheritParentConfig
: Not a real style, but allows to use the.codee-format
file from the parent directory (or its parent if there is none). If there is no parent file found it falls back to theCodee
style, and applies the changes to that.
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}"
Casing (CasingStyle
)
Control the letter casing.
Possible values:
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
: 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
! Capitalize:
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
! Capitalize:
Function foo()
Real :: var
End Function foo
LogicalConstants
: Set the casing of logical constants
! LowerCase:
.true.
.false.
! UpperCase:
.TRUE.
.FALSE.
! Capitalize:
.True.
.False.
LogicalOperators
: Set the casing of logical operators
! LowerCase:
.and.
.or.
! UpperCase:
.AND.
.OR.
! Capitalize:
.And.
.Or.
RelationalOperators
: Set the casing of logical operators
! LowerCase:
.lt.
.eq.
! UpperCase:
.LT.
.EQ.
! Capitalize:
.Lt.
.Eq.
UserDefinedOperators
: Set the casing of user defined operators
! LowerCase:
.useroperator.
! UpperCase:
.USEROPERATOR.
! Capitalize:
.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 formatting 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:
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 are:
IndentBeforeAndAfter
: Increase the level of indentation before and after itIndentBefore
: Increase the level of indentation before it onlyDoNotIndent
: Keep the current indentation level
Nested configuration flags:
ModuleContains
: Set the indentation before and after thecontains
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
FixedIndentSize (unsigned
)
Set a number of whitespaces at the beginning of each line. Defaults to 0.
! FixedIndentSize: 0
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function
! FixedIndentSize: 6
function foo(n)
integer, intent(in) :: n
integer :: i
do i=1,n
print *, i
end do
end function
ContinuationIndentSize (unsigned
)
Set the number of spaces for line continuations. Defaults to
IndentSize * 2
.
! ContinuationIndentSize: 0
subroutine foo()
integer :: &
bar
end
! ContinuationIndentSize: 4
subroutine foo()
integer :: &
bar
end
DoubleColonSeparator (DoubleColonSeparatorStyle
)
Separates the variable name from its declaration with ::
.
Possible values are:
AddAlways
: Always add::
to separate the type from the variable namePreserve
: 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:
Autodected
: Use the first detected EOL in the inputUnix
: Use\n
Windows
: Use\r\n
Preserve
: Do not normalize end of line character sequences
EndStatementFormat (EndStatementFormatStyle
)
Set the format to write the end
keyword with its corresponding structure
(e.g., end module
or end do
) and name.
Possible values are:
EndOnly
: Set only theend
keywordEndAndStructure
: Set theend
with the corresponding structure kindEndStructureAndName
: Set theend
with the corresponding structure kind and its namePreserve
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 end
and its corresponding statement.
Possible values are:
Joined
: Prefer the joined formSeparated
: Prefer the separated formPreserve
: Keep the original form as it is
Nested configuration flags:
EndAssociate
: Setendassociate
orend associate
! Joined:
associate v => myreal
endassociate
! Separated:
associate v => myreal
end associate
EndBlockConstruct
: Setendblock
orend block
! Joined:
block
endblock
! Separated:
block
end block
EndBlockData
: Setendblockdata
orend block data
! Joined:
block data
endendblockdata
! Separated
block data
end block data
EndCritical
: Setendcritical
orend critical
! Joined:
critical
endcritical
! Separated:
critical
end critical
EndTeam
: Setendteam
orend team
! Joined:
change team (t)
endteam
! Separated:
change team (t)
end team
EndDoLoop
: Setenddo
orend do
! Joined:
do i=0,n
enddo
! Separated:
do i=0,n
end do
EndEnum
: Setendenum
orend enum
! Joined:
enum
enumerator :: on, off
endenum
! Separated:
enum
enumerator :: on, off
end enum
EndEnumerationType
: Setendenumerationtype
orend enumeration type
! Joined:
enumeration type
enumerator :: on, off
endenumerationtype
! Separated
enumeration type
enumerator :: on, off
end enumeration type
EndForall
: Setendforall
orend forall
! Joined:
forall(i = 3:n)
c(i) = 0
endforall
! Separated:
forall(i = 3:n)
c(i) = 0
end forall
EndFunction
: Setendfunction
orend function
! Joined:
function foo()
endfunction foo
! Separated:
function foo()
end function foo()
EndIf
: Setendif
orend if
! Joined:
if (i == 0) then
endif
! Separated:
if (i == 0) then
end if
EndInterface
: Setendinterface
orend interface
! Joined:
interface i
endinterface i
! Separated:
interface i
end interface i
EndModule
: Setendmodule
orend module
! Joined:
module m
endmodule m
! Separated:
module m
end module m
EndModuleProcedure
: Setendprocedure
orend procedure
! Joined:
module procedure p
endprocedure p
! Separated:
module procedure p
end procedure p
EndProgram
: Setendprogram
orend program
! Joined:
program myapp
endprogram myapp
! Separated:
program myapp
end program myapp
EndSelect
: Setendselect
orend select
! Joined:
select case (k)
end select
! Separated:
select case (k)
end select
EndSubmodule
: Setendsubmodule
orend submodule
! Joined:
submodule
endsubmodule
! Separated:
submodule
end submodule
EndSubroutine
: Setendsubroutine
orend subroutine
! Joined:
subroutine foo()
endsubroutine foo
! Separated:
subroutine foo()
end subroutine foo()
EndType
: Setendtype
orend type
! Joined:
type myType
integer :: x
endtype
! Separated:
type integer :: x
end type
EndWhere
: Setendwhere
orend where
! Joined:
where(i < 1.0)
endwhere
! Separated:
where(i < 1.0)
end where
EnsureNewlineAtEOF (Boolean
)
If true
, add a newline sequence at the end of the file if it was missing.
ConsecutiveEmptyLines (unsigned
)
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.
Valid values are:
- Positive integer number (Default:
1
) - Preserve: Keep consecutive empty lines as found
subroutine foo()
a = 0
b = 1
end subroutine foo
With MaxToKeep: 1
becomes:
subroutine foo()
a = 0
b = 1
end subroutine foo
subroutine foo()
end subroutine foo
subroutine bar()
end subroutine bar
With BetweenProcedures: 1
becomes:
subroutine foo()
end subroutine foo
subroutine bar()
end subroutine bar
RemoveAtStartOfFile
: Iftrue
, removes all empty lines in the begining of the file (Default:true
)
subroutine foo()
end subroutine foo()
Becomes:
subroutine foo()
end subroutine foo()
RemoveAtEndOfFile
: Iftrue
, removes all empty lines at the end of the file
subroutine foo()
end subroutine foo()
Becomes:
subroutine foo()
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=
RemoveAlways
: Always removekind=
Preserve
: Keep the original form as it is
! AddAlways:
real(kind=4) :: i
real(kind=dp) :: d
! RemoveAlways:
real(4) :: i
real(dp) :: d
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 symbolPreserve
Keep the original form as it is
! UseSymbols:
i < 10
i == 10
! vs
i .lt. 10
i .eq. 10
SpacesAroundOperators (OperatorSpacingStyle
)
Control the use of a space before (leading) and after (trailing) operators like
+
.
Possible values of OperatorSpacingStyle
are:
OperatorSpacingStyle | Leading | Trailing | After formatting |
---|---|---|---|
NoSpaces | Remove | Remove | a+b |
Both | Add | Add | a + b |
OnlyLeading | Add | Remove | a +b |
OnlyTrailing | Remove | Add | a+ b |
Leading | Add | Preserve | a +b or a + b |
NoLeading | Remove | Preserve | a+b or a+ b |
Trailing | Preserve | Add | a+ b or a + b |
NoTrailing | Remove | Preserve | a+b or a +b |
Preserve | Preserve | Preserve | Any of the above |
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
)
If true
, turns any sequence of whitespace characters between visible
characters of a line into a single space. With the exception of string literals
and comments. For example:
answer = 'forty two' ! precomputed answer
becomes
answer = 'forty two' ! precomputed answer
RemoveSemicolons (Boolean
)
If true
, removes semicolons whenever possible
! true:
a = 5
! false:
a = 5;
RemoveTrailingWhitespace (Boolean
)
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
)
If true
, separates statements that are in the same line, delimited with a
;
, into different lines. See RemoveSemicolons
if you also want to remove the
separating semicolons.
! true:
a = 5;
b = 6
! false:
a = 5; b = 6