You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pawel Lampe edited this page Oct 1, 2024
·
3 revisions
gdformat is an uncompromising GDScript code formatter. The only configurable thing is
max line length allowed. The rest will be taken care of by gdformat in a one,
consistent way.
Formatting with gdformat
Formatting may lead to data loss, so it's highly recommended to use it along with Version Control System (VCS) e.g. git
gdformat is the uncompromising GDScript code formatter. The only configurable thing is max line length allowed (--line-length). The rest will be taken care of by gdformat in a one, consistent way.
To run a formatter you need to perform installation first. Once done, given a test.gd file:
class X:
var x=[1,2,{'a':1}]
var y=[1,2,3,] # trailing comma
func foo(a:int,b,c=[1,2,3]):
if a in c and \
b > 100:
print('foo')
func bar():
print('bar')
when you run gdformat test.gd, the test.gd file will be reformatted as follows:
class X:
var x = [1, 2, {'a': 1}]
var y = [
1,
2,
3,
] # trailing comma
func foo(a: int, b, c = [1, 2, 3]):
if a in c and b > 100:
print('foo')
func bar():
print('bar')
If the program formats your files successfully, it will return the exit code 0. Non-zero code will be returned otherwise.
Skipping certain directories
To skip certain directories, you can invoke:
gdformat --dump-default-config
to generate gdformatrc file. This file can then be modified to instruct formatter to skip certain directories: